Annotation Type RequestPart


@Retention(CLASS) @Target(PARAMETER) public @interface RequestPart

Binds one part of a multipart/form-data request body to this parameter.

@PostMapping("/avatar")
public String upload(@RequestPart("file") HttpServer.Part file) {
    store(file.getFilename(), file.getBytes());
    return "stored " + file.getSize() + " bytes";
}

The parameter is a com.codename1.backend.HttpServer.Part -- name, filename, content type and bytes -- or byte[] for the content alone, or String for a text field. A body that is not well-formed multipart is answered 400 before the method runs, as is a missing required part.

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The part's name, from its Content-Disposition.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether a request without the part is rejected.
  • Element Details

    • value

      String value
      The part's name, from its Content-Disposition. Required for the same reason RequestParam's is: a parameter's own name does not survive compilation.
    • required

      boolean required
      Whether a request without the part is rejected.
      Default:
      true