1 first to see @queryparam
Path ("/users") public class UserService {@GET @Path ("/query") public Response getusers (@QueryParam ("from") int from, @Qu Eryparam ("to") int to, @QueryParam ("by") List<string> by ("by") {return Response. status). Entity (" Getusers is called, from: ' + from + ', to: ' + to + ', by ' + orderby.tostring ()). build ();}
URL entered as: Users/query?from=100&to=200&orderby=age&orderby=name
At this point, the output is:
Getusers is called, from:100, to:200, Orderby[age, name]
Note that unlike @pathparam, the @queryparam specifies that the parameters in the URL are in the form of a key-value pair, whereas in the program
@QueryParam (' from ') int from is the value from which the URL is read out, and in @pathparem, only the value of the parameter appears in the URL, not the key value pair, for example: "/users/2011/06/30"
2, @PathParam example
@GET @Path ("{year}/{month}/{day}") Public Response getuserhistory (@PathParam (' year ') int year, @ Pathparam ("month") int month, @PathParam (' Day ') int day} {String date = year + "/" + month + "/" + Day; return RESPONSE.S Tatus. Entity ("Getuserhistory is called, Year/month/day:" + date). Build ();