Does @GET method in Spring RESTFul service implementation has to be accompanied by @Produces and @POST method needs to be followed with @Consumption?
I understood that @GET is used to read the resources from Server and hence Server needs to produce the type of response as JSON or XML.
Similarly for @POST/PUT, it can be server will consume resources hence @Consumption. But some one saying that in Spring, @Consumes is default associated and @produces need to be specified for @GET,@POST, @PUT
Only one method (@GET or @POST) is executed for a single request. So two methods can't be executed in single request. JAX-RS identifies which method (@GET or @POST) to be executed according to the request header values(@Consumes and @Produces). In my case, it is common to see both @Consumes and @Produces attached to a method.
@GET and @POST do not strictly accompany either @Produces and @Consumption. I have used @POST with both producing and consuming. In the producing case, I was posting event information, that would produce information persisted in the database for the corresponding event.
By default, a resource class can respond to and produce all MIME media types of representations specified in the HTTP request and response headers.
Hope I answered your question.
A day job? In an office? My worst nightmare! Comfort me tiny ad!