@GET: The method of the annotation tag indicates that the Get method is idempotent and safe to handle get requests.
@POST: The method of the annotation tag indicates that the POST request is processed, the Post method indicates a method of creating an operation, the Post method is a write HTTP request, and the write operation in RPC uses the Post method, whereas in rest we just use the Post method to add resources.
@DELETE: The method of the annotation tag indicates that the method is performing an operation to delete a resource whose return value can be void, that is, there is no return value.
@Consumes: On the server side, @Consumes (mediatype.application_xml) defines the type of media to consume on the server side, that is, the media type of the consumer client request entity, which can be XML, JSON, and so on.
@Produces: @Consumes (mediatype.application_xml) defines the type of media produced on the server side, that is, the media type of the response entity generated by the server side, as well as the media types such as XML, JSON, and so on.
@Path: The note can be marked on the class name or on the method name. The note receives a value parameter that represents the address that defines the resource. In addition, the resource address is the same, but the HTTP method is different two methods are completely two different rest interfaces, HTTP method and resource address together to complete the positioning of a resource.
PackageCom.zte.ems.resource;Importjavax.servlet.http.HttpServletRequest;ImportJavax.ws.rs.GET;ImportJavax.ws.rs.POST;ImportJavax.ws.rs.Path;ImportJavax.ws.rs.core.Context;Importorg.springframework.stereotype.Component, @Component @path ("/weclome") Public classJerseyresource { @GET @Path ("/wrong") Public voidgetpage (@Context httpservletrequest request) {System.out.println ("This is a Get method!" "); } @POST @Path ("/wrong") Public voidpostpage (@Context httpservletrequest request) {System.out.println ("This is a POST method!" "); }}
Take this class as an example, although the combination of @path is "/weclome/wrong", but because of the HTTP method is different, so the method of executing the body is also different.
@QueryParam: The note indicates that the query condition determines the scope of the method, and the query parameters make up the query criteria. Use @queryparam annotations in Jersey to define query parameters. Note @queryparam can also be used with annotation @defaultvaule, which is the function of the annotation @defaultvalue to preset a default value that is used when the parameter is not included in the request.
@PathParam: This annotation defines the parameter information for the path, and each parameter corresponds to a child resource.
@FormParam: This annotation represents the parameters used to define the form.
@Context: This annotation is used to parse the context parameter. (@Context HttpRequest request)
Summary of common annotations in Jersey