spring-framework / org.springframework.web.servlet.mvc.method.annotation / RequestPartMethodArgumentResolver

RequestPartMethodArgumentResolver

open class RequestPartMethodArgumentResolver : AbstractMessageConverterMethodArgumentResolver

Resolves the following method arguments:

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 org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver is configured.

Author
Rossen Stoyanchev

Author
Brian Clozel

Author
Juergen Hoeller

Since
3.1

Constructors

<init>

RequestPartMethodArgumentResolver(messageConverters: MutableList<HttpMessageConverter<*>>)

Basic constructor with converters only.

RequestPartMethodArgumentResolver(messageConverters: MutableList<HttpMessageConverter<*>>, requestResponseBodyAdvice: MutableList<Any>)

Constructor with converters and Request~ and ResponseBodyAdvice.

Functions

resolveArgument

open fun resolveArgument(parameter: MethodParameter, mavContainer: ModelAndViewContainer, request: NativeWebRequest, binderFactory: WebDataBinderFactory): Any

supportsParameter

open fun supportsParameter(parameter: MethodParameter): Boolean

Supports the following:

  • annotated with @RequestPart
  • of type MultipartFile unless annotated with @RequestParam
  • of type javax.servlet.http.Part unless annotated with @RequestParam