Annotation Interface Content


@Target({PARAMETER,METHOD}) @Retention(RUNTIME) public @interface Content
Should be used on EntryPath-annotated methods on Controller-annotated classes.

On parameters, the request body content is passed in as the following:

  • If the content type is any of the application/xml equivalents and a XMLDriver component is found, the driver is used to convert to the target type.
  • If the content type is application/json and a JSONDriver is found, the driver is used to convert to the target type.
  • Else, if the content is anything else, the following types are valid as a target type:
  • Otherwise, an error is thrown.
Note that its use on a parameter is worthless if the request method is not RequestMethod.POST, RequestMethod.PUT, or RequestMethod.PATCH.

If on a method, this converts the returned object after running the method into data that is put into the response body.

  • If return type is a SmallResponse, its content is the object to convert (other headers and statuses are set on the response), and conversion continues below for the content...
  • If return type is a SmallModelView, the view is resolved and written to the response.
  • If return type is a File,
    • ...the content type is changed to the file's predicted MIME-type and the content is the file's content, verbatim. Unknown type is application/octet-stream.
    • ...and is null, this sends a 404.
  • If return type is a Reader, CharSequence, String, StringBuilder, or StringBuffer, plain text is sent back. Content type is text/plain if unspecified.
  • If return type is byte[] or ByteBuffer binary data is sent back. Content type is application/octet-stream if unspecified.
  • If return type is any other object type,
    • ...and a XMLDriver component is found, and the specified content type is application/xml or an XML subtype, the object is converted to XML.
    • ...and a JSONDriver component is found, content type is application/json and the object is converted.
If a String value is given on this annotation, it is interpreted as the forced MIME-Type to use, but only for File, String and binary output.
Author:
Matthew Tropiano
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
     
  • Element Details

    • value

      String value
      Returns:
      the forced MIME-Type.
      Default:
      ""