I have some code as a rest resource :
@GET
@Produces ( { "application/json" } )
@Path ("/some/{some}")
public JSONObject retrieveSome(@PathParam("some") final String some) {
//body of the method
}
What does the 开发者_如何学JAVA@Path ("/some/{some}")
mean?
The @Path
annotation creates a URI template of sorts. The {some}
portion gives a name to that portion of the resource path. So if the URI is /some/1234
then retrieveSome
will be invoked with the some
parameter set to 1234
. So the @Path
annotation creates the template and the @PathParam
annotation extracts a named portion of the template. Read @Path Annotation and URI Path Templates for more details.
精彩评论