JAX-RS annotations

The most important annotations in JAX-RS are listed in the following table:

Annotation

Meaning

@PATH

Sets the path to base URL + /your_path. The base URL is based on your application name, the servlet, and the URL pattern from the web.xml configuration file.

@POST

Indicates that the following method will answer to an HTTP POST request.

@GET

Indicates that the following method will answer to an HTTP GET request.

@PUT

Indicates that the following method will answer to an HTTP PUT request.

@DELETE

Indicates that the following method will answer to an HTTP DELETE request.

@Produces

Defines which MIME type is delivered by a method annotated with @GET. It can be "text/plain", "application/xml" ...

Get Docker and Kubernetes for Java Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.