JAX-RS REST @Produces Example

Previously we have learnt about how to get parameters using @PathParam, @QueryParam, @Context, @FormParam@MatrixParam annotations, In this article we will learn how to send different types of response back to the user using @Produces annotation.

@Produces annotation is used to specify the MIME media types that a resource can produce and send back to the client. @Produces can be applied at both class level and method level, If applied on class level all the methods can produce the specified MIME types by default. If it is applied at the method level, it overrides any @Produces annotations applied at the class level.
[Read more…]