okay so i have created restful webservice.now how to create a path for a user \"abc\".
Something like this
http://stackoverflow.com/user/abc
Use the @Path
and @PathParam
annotations:
@Path("/user/{uname}")
@PUT
@Consumes("text/plain")
public void putUser(@PathParam("uname") String uname, String password) {
// ..
}
If you PUT
to /user/joe
with a body of s3cret
, then uname
will be joe
and password
will be s3cret
.
I use PUT
because the URL you want to use implies that the username is set by the client. /user
is the collection resource of all users.
Edit: Since this method will change the server state by creating a new user, PUT
or POST
must be used. GET
must not change the server state.