Class RequestParamMethodArgumentResolver

java.lang.Object
org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver
org.springframework.web.method.annotation.RequestParamMethodArgumentResolver
All Implemented Interfaces:
HandlerMethodArgumentResolver, UriComponentsContributor

public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethodArgumentResolver implements UriComponentsContributor
Resolves method arguments annotated with @RequestParam, arguments of type MultipartFile in conjunction with Spring's MultipartResolver abstraction, and arguments of type jakarta.servlet.http.Part in conjunction with Servlet 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.

Since:
3.1
Author:
Arjen Poutsma, Rossen Stoyanchev, Brian Clozel
See Also:
  • Constructor Details

    • RequestParamMethodArgumentResolver

      public RequestParamMethodArgumentResolver(boolean useDefaultResolution)
      Create a new RequestParamMethodArgumentResolver instance.
      Parameters:
      useDefaultResolution - in default resolution mode a method argument that is a simple type, as defined in BeanUtils.isSimpleProperty(java.lang.Class<?>), is treated as a request parameter even if it isn't annotated, the request parameter name is derived from the method parameter name.
    • RequestParamMethodArgumentResolver

      public RequestParamMethodArgumentResolver(@Nullable org.springframework.beans.factory.config.ConfigurableBeanFactory beanFactory, boolean useDefaultResolution)
      Create a new RequestParamMethodArgumentResolver instance.
      Parameters:
      beanFactory - a bean factory used for resolving ${...} placeholder and #{...} SpEL expressions in default values, or null if default values are not expected to contain expressions
      useDefaultResolution - in default resolution mode a method argument that is a simple type, as defined in BeanUtils.isSimpleProperty(java.lang.Class<?>), is treated as a request parameter even if it isn't annotated, the request parameter name is derived from the method parameter name.
  • Method Details