spring-framework / org.springframework.web.method.annotation / RequestParamMethodArgumentResolver

RequestParamMethodArgumentResolver

open class RequestParamMethodArgumentResolver : AbstractNamedValueMethodArgumentResolver, UriComponentsContributor

Resolves method arguments annotated with @RequestParam, arguments of type MultipartFile in conjunction with Spring's MultipartResolver abstraction, and arguments of type javax.servlet.http.Part in conjunction with Servlet 3.0 multipart requests. This resolver can also be created in default resolution mode in which simple types (int, long, etc.) not annotated with RequestParam are also treated as request parameters with the parameter name derived from the argument name.

If the method parameter type is Map, the name specified in the annotation is used to resolve the request parameter String value. The value is then converted to a Map via type conversion assuming a suitable Converter or PropertyEditor has been registered. Or if a request parameter name is not specified the RequestParamMapMethodArgumentResolver is used instead to provide access to all request parameters in the form of a map.

A WebDataBinder is invoked to apply type conversion to resolved request header values that don't yet match the method parameter type.

Author
Arjen Poutsma

Author
Rossen Stoyanchev

Author
Brian Clozel

Since
3.1

See Also
RequestParamMapMethodArgumentResolver

Constructors

<init>

RequestParamMethodArgumentResolver(useDefaultResolution: Boolean)
RequestParamMethodArgumentResolver(beanFactory: ConfigurableBeanFactory, useDefaultResolution: Boolean)

Functions

contributeMethodArgument

open fun contributeMethodArgument(parameter: MethodParameter, value: Any, builder: UriComponentsBuilder, uriVariables: MutableMap<String, Any>, conversionService: ConversionService): Unit

supportsParameter

open fun supportsParameter(parameter: MethodParameter): Boolean

Supports the following:

  • @RequestParam-annotated method arguments. This excludes Map params where the annotation doesn't specify a name. See RequestParamMapMethodArgumentResolver instead for such params.
  • Arguments of type MultipartFile unless annotated with @RequestPart.
  • Arguments of type javax.servlet.http.Part unless annotated with @RequestPart.
  • In default resolution mode, simple type arguments even if not with @RequestParam.

Inherited Functions

resolveArgument

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