Package jakarta.ws.rs

Annotation Type Produces


@Inherited @Target({TYPE,METHOD}) @Retention(RUNTIME) @Documented public @interface Produces
Defines the media type(s) that the methods of a resource class or MessageBodyWriter can produce. If not specified then a container will assume that any type can be produced. Method level annotations override a class level annotation. A container is responsible for ensuring that the method invoked is capable of producing one of the media types requested in the HTTP request. If no such method is available the container must respond with a HTTP "406 Not Acceptable" as specified by RFC 2616.

A method for which there is a single-valued @Produces is not required to set the media type of representations that it produces: the container will use the value of the @Produces when sending a response.

Since:
1.0
Author:
Paul Sandoz, Marc Hadley
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    A list of media types.
  • Element Details

    • value

      String[] value
      A list of media types. Each entry may specify a single type or consist of a comma separated list of types, with any leading or trailing white-spaces in a single type entry being ignored. For example:
       { "image/jpeg, image/gif ", " image/png" }
       
      Use of the comma-separated form allows definition of a common string constant for use on multiple targets.
      Returns:
      media types to accept.
      Default:
      {"*/*"}