Here I want to specify the id in the path of a resource to get the respective object.
Example:
Consider we have 10 users. The resource URI path to get users is /users
.
Now I want to fetch a single user by passing user id in URL like /users/1234
.
How can I achieve this using Jersey?
Use a @PathParam
.
@GET
@Path("/users/{id}")
public Response getUser(@PathParam int id) {
// Fetch user and return Response.
}
you can use like :
@Path("/users/{userid}")
public Response getUsr(@PathParam("userid") String userId) {
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.