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

Package org.springframework.web.method.annotation

Types

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.

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:

  • Obtain named value information for a method parameter
  • Resolve names into argument values
  • Handle missing argument values when argument values are required
  • Optionally handle a resolved value

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.

AbstractWebArgumentResolverAdapter

abstract class AbstractWebArgumentResolverAdapter : HandlerMethodArgumentResolver

An abstract base class adapting a WebArgumentResolver to the HandlerMethodArgumentResolver contract.

Note: This class is provided for backwards compatibility. However it is recommended to re-write a WebArgumentResolver as HandlerMethodArgumentResolver. Since #supportsParameter can only be implemented by actually resolving the value and then checking the result is not WebArgumentResolver#UNRESOLVED any exceptions raised must be absorbed and ignored since it's not clear whether the adapter doesn't support the parameter or whether it failed for an internal reason. The HandlerMethodArgumentResolver contract also provides access to model attributes and to WebDataBinderFactory (for type conversion).

ErrorsMethodArgumentResolver

open class ErrorsMethodArgumentResolver : HandlerMethodArgumentResolver

Resolves Errors method arguments.

An Errors method argument is expected to appear immediately after the model attribute in the method signature. It is resolved by expecting the last two attributes added to the model to be the model attribute and its BindingResult.

ExceptionHandlerMethodResolver

open class ExceptionHandlerMethodResolver

Discovers ExceptionHandler methods in a given class, including all of its superclasses, and helps to resolve a given Exception to the exception types supported by a given Method.

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.

InitBinderDataBinderFactory

open class InitBinderDataBinderFactory : DefaultDataBinderFactory

Adds initialization to a WebDataBinder via @InitBinder methods.

MapMethodProcessor

open class MapMethodProcessor : HandlerMethodArgumentResolver, HandlerMethodReturnValueHandler

Resolves Map method arguments and handles Map return values.

A Map return value can be interpreted in more than one ways depending on the presence of annotations like @ModelAttribute or @ResponseBody. Therefore this handler should be configured after the handlers that support these annotations.

ModelAttributeMethodProcessor

open class ModelAttributeMethodProcessor : HandlerMethodArgumentResolver, HandlerMethodReturnValueHandler

Resolve @ModelAttribute annotated method arguments and handle return values from @ModelAttribute annotated methods.

Model attributes are obtained from the model or created with a default constructor (and then added to the model). Once created the attribute is populated via data binding to Servlet request parameters. Validation may be applied if the argument is annotated with @javax.validation.Valid. or Spring's own @org.springframework.validation.annotation.Validated.

When this handler is created with annotationNotRequired=true any non-simple type argument and return value is regarded as a model attribute with or without the presence of an @ModelAttribute.

ModelFactory

class ModelFactory

Assist with initialization of the Model before controller method invocation and with updates to it after the invocation.

On initialization the model is populated with attributes temporarily stored in the session and through the invocation of @ModelAttribute methods.

On update model attributes are synchronized with the session and also BindingResult attributes are added if missing.

ModelMethodProcessor

open class ModelMethodProcessor : HandlerMethodArgumentResolver, HandlerMethodReturnValueHandler

Resolves Model arguments and handles Model return values.

A Model return type has a set purpose. Therefore this handler should be configured ahead of handlers that support any return value type annotated with @ModelAttribute or @ResponseBody to ensure they don't take over.

RequestHeaderMapMethodArgumentResolver

open class RequestHeaderMapMethodArgumentResolver : HandlerMethodArgumentResolver

Resolves Map method arguments annotated with @RequestHeader. For individual header values annotated with @RequestHeader see RequestHeaderMethodArgumentResolver instead.

The created Map contains all request header name/value pairs. The method parameter type may be a MultiValueMap to receive all values for a header, not only the first one.

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.

RequestParamMapMethodArgumentResolver

open class RequestParamMapMethodArgumentResolver : HandlerMethodArgumentResolver

Resolves Map method arguments annotated with an @RequestParam where the annotation does not specify a request parameter name. See RequestParamMethodArgumentResolver for resolving Map method arguments with a request parameter name.

The created Map contains all request parameter name/value pairs. If the method parameter type is MultiValueMap instead, the created map contains all request parameters and all there values for cases where request parameters have multiple values.

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.

SessionAttributesHandler

open class SessionAttributesHandler

Manages controller-specific session attributes declared via SessionAttributes. Actual storage is delegated to a SessionAttributeStore instance.

When a controller annotated with @SessionAttributes adds attributes to its model, those attributes are checked against names and types specified via @SessionAttributes. Matching model attributes are saved in the HTTP session and remain there until the controller calls SessionStatus#setComplete().

SessionStatusMethodArgumentResolver

open class SessionStatusMethodArgumentResolver : HandlerMethodArgumentResolver

Resolves a SessionStatus argument by obtaining it from the ModelAndViewContainer.

Exceptions

MethodArgumentConversionNotSupportedException

open class MethodArgumentConversionNotSupportedException : ConversionNotSupportedException

A ConversionNotSupportedException raised while resolving a method argument. Provides access to the target org.springframework.core.MethodParameter.

MethodArgumentTypeMismatchException

open class MethodArgumentTypeMismatchException : TypeMismatchException

A TypeMismatchException raised while resolving a controller method argument. Provides access to the target org.springframework.core.MethodParameter.