休息路径问题

时间:2010-12-22 00:07:24

标签: web-services rest resources

我有一些代码作为休息资源:

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

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

1 个答案:

答案 0 :(得分:3)

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