2016-08-18 21 views
0
@GET 
    @Produces(MediaType.APPLICATION_JSON) 
    @Consumes(MediaType.APPLICATION_JSON) 
    @Path("/categories") 
    public Response getAllCategories(@QueryParam(value = "code") String country_code) { 

     return userService.getAllCategories(country_code); 
} 

提取参数我的URL: “?/用户/类别代码= + 91”如何从@QueryParam

我怎样才能在RESTful网络服务请求中提取参数 “91”。

+0

代码中没有什么Spring相关的,为什么它被标记为spring和spring-mvc? –

+0

尝试删除括号中的值。正如'@QueryParam(“code”)' –

+0

@YoungMillie value =“code”完全等于只写“code”。 –

回答

0

@QueryParam是JAX-RS。如果你想使用Spring,相应的注释是@RequestParam

public Response getAllCategories(@RequestParam("code") String country_code) { 
... 
} 

但当然,@Path等也没有春天的,因此,或许你应该问自己,如果你真的想使用Spring ...