Class RequestPartMethodArgumentResolver
- All Implemented Interfaces:
- HandlerMethodArgumentResolver
- Annotated with @RequestPart
- Of type MultipartFilein conjunction with Spring'sMultipartResolverabstraction
- Of type jakarta.servlet.http.Partin 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
 DefaultHandlerExceptionResolver
 is configured.
- Since:
- 3.1
- Author:
- Rossen Stoyanchev, Brian Clozel, Juergen Hoeller
- 
Field SummaryFields inherited from class org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolverlogger, messageConverters
- 
Constructor SummaryConstructorsConstructorDescriptionRequestPartMethodArgumentResolver(List<HttpMessageConverter<?>> messageConverters) Basic constructor with converters only.RequestPartMethodArgumentResolver(List<HttpMessageConverter<?>> messageConverters, List<Object> requestResponseBodyAdvice) Constructor with converters andRequestBodyAdviceandResponseBodyAdvice.
- 
Method SummaryModifier and TypeMethodDescriptionresolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest request, WebDataBinderFactory binderFactory) Resolves a method parameter into an argument value from a given request.booleansupportsParameter(MethodParameter parameter) Whether the given method parameter is supported as multipart.Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolveradaptArgumentIfNecessary, createInputMessage, getSupportedMediaTypes, isBindExceptionRequired, readWithMessageConverters, readWithMessageConverters, validateIfApplicable
- 
Constructor Details- 
RequestPartMethodArgumentResolverBasic constructor with converters only.
- 
RequestPartMethodArgumentResolverpublic RequestPartMethodArgumentResolver(List<HttpMessageConverter<?>> messageConverters, List<Object> requestResponseBodyAdvice) Constructor with converters andRequestBodyAdviceandResponseBodyAdvice.
 
- 
- 
Method Details- 
supportsParameterWhether the given method parameter is supported as multipart. Supports the following method parameters:- annotated with @RequestPart
- of type MultipartFileunless annotated with@RequestParam
- of type jakarta.servlet.http.Partunless annotated with@RequestParam
 - Parameters:
- parameter- the method parameter to check
- Returns:
- trueif this resolver supports the supplied parameter;- falseotherwise
 
- annotated with 
- 
resolveArgument@Nullable public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, NativeWebRequest request, @Nullable WebDataBinderFactory binderFactory) throws Exception Description copied from interface:HandlerMethodArgumentResolverResolves a method parameter into an argument value from a given request. AModelAndViewContainerprovides access to the model for the request. AWebDataBinderFactoryprovides a way to create aWebDataBinderinstance when needed for data binding and type conversion purposes.- Parameters:
- parameter- the method parameter to resolve. This parameter must have previously been passed to- HandlerMethodArgumentResolver.supportsParameter(org.springframework.core.MethodParameter)which must have returned- true.
- mavContainer- the ModelAndViewContainer for the current request
- request- the current request
- binderFactory- a factory for creating- WebDataBinderinstances
- Returns:
- the resolved argument value, or nullif not resolvable
- Throws:
- Exception- in case of errors with the preparation of argument values
 
 
-