2016-08-18 23 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 ...