RequestPart
MultipartFile in conjunction with Spring's MultipartResolver abstraction
jakarta.servlet.http.Part in conjunction with Servlet multipart requests
When a parameter is annotated with @RequestPart, the content of the part is
passed through an HttpMessageConverter to resolve the method argument with the
'Content-Type' of the request part in mind. This is analogous to what @RequestBody
does to resolve an argument based on the content of a regular request.
When a parameter is not annotated with @RequestPart or the name of
the part is not specified, the request part's name is derived from the name of
the method argument.
Automatic validation may be applied if the argument is annotated with any
annotations that trigger validation. In case of validation failure, a
MethodArgumentNotValidException is raised and a 400 response status code returned if the
org.
is configured.
| Access | Constructor and Description |
|---|---|
| public | RequestPartMethodArgumentResolver(List<HttpMessageConverter<?>> messageConverters)
Basic constructor with converters only. |
| public | RequestPartMethodArgumentResolver(List<HttpMessageConverter<?>> messageConverters, List<Object> requestResponseBodyAdvice)
Constructor with converters and |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | closeStreamIfNecessary(InputStream body)
Allow for closing the body stream if necessary, e.g. for part streams in a multipart request. |
| private String | |
| public Object | resolveArgument(MethodParameter
the method parameter to resolve. This parameter must
have previously been passed to parameter, ModelAndViewContainer supportsParameter which must
have returned true.the ModelAndViewContainer for the current request mavContainer, NativeWebRequest the current request request, WebDataBinderFactory a factory for creating binderFactory)WebDataBinder instancesImplements org. Resolves a method parameter into an argument value from a given request. |
| public boolean | supportsParameter(MethodParameter
the method parameter to check parameter)Implements org. Whether the given method parameter is supported as multipart. |
| RequestPartMethodArgumentResolver | back to summary |
|---|---|
| public RequestPartMethodArgumentResolver(List<HttpMessageConverter<?>> messageConverters) Basic constructor with converters only. | |
| RequestPartMethodArgumentResolver | back to summary |
|---|---|
| public RequestPartMethodArgumentResolver(List<HttpMessageConverter<?>> messageConverters, List<Object> requestResponseBodyAdvice) Constructor with converters and | |
| closeStreamIfNecessary | back to summary |
|---|---|
| pack-priv void closeStreamIfNecessary(InputStream body) Allow for closing the body stream if necessary, e.g. for part streams in a multipart request.
| |
| getPartName | back to summary |
|---|---|
| private String getPartName(MethodParameter methodParam, RequestPart requestPart) | |
| resolveArgument | back to summary |
|---|---|
| public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest request, WebDataBinderFactory binderFactory) throws Exception Implements org. Doc from org. Resolves a method parameter into an argument value from a given request.
A
| |
| supportsParameter | back to summary |
|---|---|
| public boolean supportsParameter(MethodParameter parameter) Implements org. Whether the given method parameter is supported as multipart. Supports the following method parameters:
| |