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

AbstractNamedValueMethodArgumentResolver

abstract class AbstractNamedValueMethodArgumentResolver : HandlerMethodArgumentResolver

Abstract base class for resolving method arguments from a named value. Request parameters, request headers, and path variables are examples of named values. Each may have a name, a required flag, and a default value.

Subclasses define how to do the following:

A default value string can contain ${...} placeholders and Spring Expression Language #{...} expressions. For this to work a ConfigurableBeanFactory must be supplied to the class constructor.

A WebDataBinder is created to apply type conversion to the resolved argument value if it doesn't match the method parameter type.

Author
Arjen Poutsma

Author
Rossen Stoyanchev

Author
Juergen Hoeller

Since
3.1

Constructors

<init>

AbstractNamedValueMethodArgumentResolver()AbstractNamedValueMethodArgumentResolver(beanFactory: ConfigurableBeanFactory)

Functions

resolveArgument

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

Inherited Functions

supportsParameter

abstract fun supportsParameter(parameter: MethodParameter): Boolean

Whether the given MethodParameter is supported by this resolver.

Inheritors

AbstractCookieValueMethodArgumentResolver

abstract class AbstractCookieValueMethodArgumentResolver : AbstractNamedValueMethodArgumentResolver

A base abstract class to resolve method arguments annotated with @CookieValue. Subclasses extract the cookie value from the request.

An @CookieValue is a named value that is resolved from a cookie. It has a required flag and a default value to fall back on when the cookie does not exist.

A WebDataBinder may be invoked to apply type conversion to the resolved cookie value.

ExpressionValueMethodArgumentResolver

open class ExpressionValueMethodArgumentResolver : AbstractNamedValueMethodArgumentResolver

Resolves method arguments annotated with @Value.

An @Value does not have a name but gets resolved from the default value string, which may contain ${...} placeholder or Spring Expression Language #{...} expressions.

A WebDataBinder may be invoked to apply type conversion to resolved argument value.

MatrixVariableMethodArgumentResolver

open class MatrixVariableMethodArgumentResolver : AbstractNamedValueMethodArgumentResolver

Resolves arguments annotated with MatrixVariable.

If the method parameter is of type Map it will by resolved by MatrixVariableMapMethodArgumentResolver instead unless the annotation specifies a name in which case it is considered to be a single attribute of type map (vs multiple attributes collected in a map).

PathVariableMethodArgumentResolver

open class PathVariableMethodArgumentResolver : AbstractNamedValueMethodArgumentResolver, UriComponentsContributor

Resolves method arguments annotated with an @PathVariable.

An @PathVariable is a named value that gets resolved from a URI template variable. It is always required and does not have a default value to fall back on. See the base class org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver for more information on how named values are processed.

If the method parameter type is Map, the name specified in the annotation is used to resolve the URI variable String value. The value is then converted to a Map via type conversion, assuming a suitable Converter or PropertyEditor has been registered.

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

RequestAttributeMethodArgumentResolver

open class RequestAttributeMethodArgumentResolver : AbstractNamedValueMethodArgumentResolver

Resolves method arguments annotated with an @RequestAttribute.

RequestHeaderMethodArgumentResolver

open class RequestHeaderMethodArgumentResolver : AbstractNamedValueMethodArgumentResolver

Resolves method arguments annotated with @RequestHeader except for Map arguments. See RequestHeaderMapMethodArgumentResolver for details on Map arguments annotated with @RequestHeader.

An @RequestHeader is a named value resolved from a request header. It has a required flag and a default value to fall back on when the request header does not exist.

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

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.

SessionAttributeMethodArgumentResolver

open class SessionAttributeMethodArgumentResolver : AbstractNamedValueMethodArgumentResolver

Resolves method arguments annotated with an @SessionAttribute.