org.springframework.web.servlet.mvc.method.annotation
Class RequestPartMethodArgumentResolver
java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver
org.springframework.web.servlet.mvc.method.annotation.RequestPartMethodArgumentResolver
- All Implemented Interfaces:
- org.springframework.web.method.support.HandlerMethodArgumentResolver
public class RequestPartMethodArgumentResolver
- extends AbstractMessageConverterMethodArgumentResolver
Resolves the following method arguments:
- Annotated with
@RequestPart
- Of type
MultipartFile in conjunction with Spring's
MultipartResolver abstraction
- Of type
javax.servlet.http.Part in conjunction with
Servlet 3.0 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 or the name of the part is not specified,
it is derived from the name of the method argument.
Automatic validation may be applied if the argument is annotated with
@javax.validation.Valid. In case of validation failure, a
MethodArgumentNotValidException is raised and a 400 response status
code returned if DefaultHandlerExceptionResolver is configured.
- Since:
- 3.1
- Author:
- Rossen Stoyanchev
|
Method Summary |
java.lang.Object |
resolveArgument(org.springframework.core.MethodParameter parameter,
org.springframework.web.method.support.ModelAndViewContainer mavContainer,
org.springframework.web.context.request.NativeWebRequest request,
org.springframework.web.bind.support.WebDataBinderFactory binderFactory)
|
boolean |
supportsParameter(org.springframework.core.MethodParameter parameter)
Supports the following:
Annotated with @RequestPart
Of type MultipartFile unless annotated with @RequestParam. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RequestPartMethodArgumentResolver
public RequestPartMethodArgumentResolver(java.util.List<org.springframework.http.converter.HttpMessageConverter<?>> messageConverters)
supportsParameter
public boolean supportsParameter(org.springframework.core.MethodParameter parameter)
- Supports the following:
- Annotated with
@RequestPart
- Of type
MultipartFile unless annotated with @RequestParam.
- Of type
javax.servlet.http.Part unless annotated with @RequestParam.
resolveArgument
public java.lang.Object resolveArgument(org.springframework.core.MethodParameter parameter,
org.springframework.web.method.support.ModelAndViewContainer mavContainer,
org.springframework.web.context.request.NativeWebRequest request,
org.springframework.web.bind.support.WebDataBinderFactory binderFactory)
throws java.lang.Exception
- Throws:
java.lang.Exception