2010-12-22 46 views
0

我有一些代码为REST资源:休息路径问题

@GET 
@Produces ({ "application/json" }) 
@Path ("/some/{some}") 
public JSONObject retrieveSome(@PathParam("some") final String some) { 
    //body of the method 
} 

什么是@Path ("/some/{some}")是什么意思?

回答

3

@Path注释会创建一个排序的URI模板。 {some}部分给出了该资源路径部分的名称。所以如果URI是/some/1234那么retrieveSome将被调用some参数设置为1234。因此,@Path注释会创建模板,并且@PathParam注释会提取模板的命名部分。请阅读@Path Annotation and URI Path Templates了解更多详情。