Annotation Interface Attachment


@Target(METHOD) @Retention(RUNTIME) public @interface Attachment
Should be used on EntryPath-annotated methods on Controller-annotated classes.

This turns the method return body content into an "attachment" via Content-Disposition headers (file downloads).

Most effective on File return types.

  • If return type is a File, the content type is changed to the file's predicted MIME-type, the content is the file's content, verbatim, and the output filename is the file's name. If the file is null, this sends a 404.
  • If return type is a String, StringBuilder, or StringBuffer, plain text is sent back. Content type is text/plain.
  • If return type is byte[], binary data is sent back. Content type is application/octet-stream, and the output filename is the page name.
  • 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
    Forced MIME-Type.
  • Element Details

    • value

      String value
      Forced MIME-Type.
      Returns:
      MIME-Type name. Default is empty string.
      Default:
      ""