@GET
, @PUT
, @POST
, and @DELETE
are the resource method designator annotations that are defined by JAX-RS and correspond to the similarly named HTTP methods. The behavior of a resource is determined by the type of HTTP methods to which the resource is responding.
This method is used to retrieve (or read) a representation of a resource. According to the design of the HTTP specification, GET (along with HEAD) requests are used only to read data, and not to change it. They are considered to be safe when they are used in this manner. This means that they can be called without the risk of data modification or corruption. The following example shows the use of the GET
method:
... @GET public String getUser() { System.out.println("GET"); return "Hello User"; } ...
Here, we have used a simple method, getUser()
. The @GET
annotation is a request method designator defined by JAX-RS. In this example, the annotated Java method will process the HTTP GET requests. The behavior of a resource...