Generally, all entity body parameters are the parameter without any annotation. Such as with JSON or XML, you would see
@POST
@Consumes({"application/json", "application/xml"})
public Response post(RequestEntity entity) {
}
Here, the MessageBodyReader
that handles JSON or XML would be used to handle deserializing the entity stream into the RequestEntity
.
This is the same with FormDataMultiPart
. There is a MessageBodyReader
to handle deserializing the entire multipart stream and creating the FormDataBodyPart
for the Jersey runtime to pass to the resource method when it is called.
@FormDataParam
is treated more like @FormParam
, @PathParam
, @QueryParam
, etc. We can have multiple parameters. Each parameter for this annotation represent a single part of the multipart request.
So we have the option to either get the entire request into a single entity with FormDataMultiPart
; in which case we would extract the parts programmatically. Or we can declaratively extract each part using the @FormDataParam
annotation, where the value of the annotation would be the name of the part.
If we used FormDataMultiPart
, we would have to extract all the parts manually from it. We would use this in such a case where the name of each part is not known. Or there are many parts, where declaring each one is tedious work or ugly to the developer.