Java Reference
In-Depth Information
Resource methods
In JAX-RS, annotations that correspond to the HTTP methods are called resourcemethods.
These include
@GET
,
@POST
,
@PUT
,
@DELETE
, and
@HEAD
. Like your
sayHello
method, these
methods must be declared
public
. You can define your own custom request method designat-
or, if, for example, you'd like to create an alternate for one of the HTTP methods.
The return types for resource methods are limited to
void
,
javax.ws.rs.core.Response
,
javax.ws.rs.core.GenericEntity
, or another Java type.
If your method returns
void
, the response will be an empty method body with a 204 status
code, which indicates that the request was successfully processed but the response doesn't
have a message body. We'll look at the other response types in later sections.
NOTE
The annotation value in
@Path
is automatically encoded, so
@Path("product list")
is identical
to
@Path("products%20list)
.