Top Description Inners Fields Constructors Methods
org.springframework.web.servlet.mvc.method.annotation

public Class RequestMappingHandlerAdapter

extends AbstractHandlerMethodAdapter
implements BeanFactoryAware, InitializingBean
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.Aware
Imports
java.lang.reflect.Method, java.util.ArrayList, .LinkedHashMap, .List, .Map, .Set, java.util.concurrent.Callable, .ConcurrentHashMap, java.util.function.Predicate, jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, .HttpSession, org.springframework.beans.factory.BeanFactory, .BeanFactoryAware, .InitializingBean, org.springframework.beans.factory.config.ConfigurableBeanFactory, org.springframework.core.DefaultParameterNameDiscoverer, .KotlinDetector, .MethodIntrospector, .MethodParameter, .ParameterNameDiscoverer, .ReactiveAdapterRegistry, org.springframework.core.annotation.AnnotatedElementUtils, org.springframework.core.log.LogFormatUtils, org.springframework.core.task.AsyncTaskExecutor, .SimpleAsyncTaskExecutor, org.springframework.http.converter.ByteArrayHttpMessageConverter, .HttpMessageConverter, .StringHttpMessageConverter, org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter, org.springframework.lang.Nullable, org.springframework.ui.ModelMap, org.springframework.util.Assert, .ClassUtils, .CollectionUtils, .ReflectionUtils.MethodFilter, org.springframework.validation.method.MethodValidator, org.springframework.web.accept.ContentNegotiationManager, org.springframework.web.bind.annotation.InitBinder, .ModelAttribute, .RequestMapping, org.springframework.web.bind.support.DefaultDataBinderFactory, .DefaultSessionAttributeStore, .SessionAttributeStore, .WebBindingInitializer, .WebDataBinderFactory, org.springframework.web.context.request.NativeWebRequest, .ServletWebRequest, .WebRequest, org.springframework.web.context.request.async.AsyncWebRequest, .CallableProcessingInterceptor, .DeferredResultProcessingInterceptor, .WebAsyncManager, .WebAsyncTask, .WebAsyncUtils, org.springframework.web.method.ControllerAdviceBean, .HandlerMethod, org.springframework.web.method.annotation.ErrorsMethodArgumentResolver, .ExpressionValueMethodArgumentResolver, .HandlerMethodValidator, .InitBinderDataBinderFactory, .MapMethodProcessor, .ModelAttributeMethodProcessor, .ModelFactory, .ModelMethodProcessor, .RequestHeaderMapMethodArgumentResolver, .RequestHeaderMethodArgumentResolver, .RequestParamMapMethodArgumentResolver, .RequestParamMethodArgumentResolver, .SessionAttributesHandler, .SessionStatusMethodArgumentResolver, org.springframework.web.method.support.HandlerMethodArgumentResolver, .HandlerMethodArgumentResolverComposite, .HandlerMethodReturnValueHandler, .HandlerMethodReturnValueHandlerComposite, .InvocableHandlerMethod, .ModelAndViewContainer, org.springframework.web.servlet.ModelAndView, .View, org.springframework.web.servlet.mvc.annotation.ModelAndViewResolver, org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter, org.springframework.web.servlet.mvc.support.RedirectAttributes, org.springframework.web.servlet.support.RequestContextUtils, org.springframework.web.util.WebUtils

Extension of AbstractHandlerMethodAdapter that supports @RequestMapping annotated HandlerMethods.

Support for custom argument and return value types can be added via setCustomArgumentResolvers and setCustomReturnValueHandlers, or alternatively, to re-configure all argument and return value types, use setArgumentResolvers and setReturnValueHandlers.

Authors
Rossen Stoyanchev, Juergen Hoeller, Sebastien Deleuze
Since
3.1
See Also
HandlerMethodArgumentResolver, HandlerMethodReturnValueHandler

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
RequestMappingHandlerAdapter.MvcSimpleAsyncTaskExecutor

References Deprecated SimpleAsyncTaskExecutor is deprecated or references (maybe indirectly) at least one deprecated element.
A default Spring MVC AsyncTaskExecutor that warns if used.

Field Summary

Modifier and TypeField and Description
private HandlerMethodArgumentResolverComposite
private Long
private static final boolean
private ConfigurableBeanFactory
private int
private CallableProcessingInterceptor[]
private ContentNegotiationManager
private List<HandlerMethodArgumentResolver>
private List<HandlerMethodReturnValueHandler>
private DeferredResultProcessingInterceptor[]
private boolean
public static final ReflectionUtils.MethodFilter
INIT_BINDER_METHODS

MethodFilter that matches @InitBinder methods.

private final Map<ControllerAdviceBean, Set<Method>>
private HandlerMethodArgumentResolverComposite
private final Map<Class<?>, Set<Method>>
private final List<HttpMessageConverter<?>>
private MethodValidator
public static final ReflectionUtils.MethodFilter
MODEL_ATTRIBUTE_METHODS

MethodFilter that matches @ModelAttribute methods.

private List<ModelAndViewResolver>
private final Map<ControllerAdviceBean, Set<Method>>
private final Map<Class<?>, Set<Method>>
private ParameterNameDiscoverer
private ReactiveAdapterRegistry
private final List<Object>
private HandlerMethodReturnValueHandlerComposite
private final Map<Class<?>, SessionAttributesHandler>
private SessionAttributeStore
private boolean
private AsyncTaskExecutor
private WebBindingInitializer

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.

This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

protected InitBinderDataBinderFactory

Returns:

the InitBinderDataBinderFactory instance to use
createDataBinderFactory
(List<InvocableHandlerMethod>
@InitBinder methods
binderMethods
)

Template method to create a new InitBinderDataBinderFactory instance.

private InvocableHandlerMethod
protected ServletInvocableHandlerMethod

Returns:

the corresponding ServletInvocableHandlerMethod (or custom subclass thereof)
createInvocableHandlerMethod
(HandlerMethod
the HandlerMethod definition
handlerMethod
)

Create a ServletInvocableHandlerMethod from the given HandlerMethod definition.

private InvocableHandlerMethod
public List<HandlerMethodArgumentResolver>
getArgumentResolvers()

Return the configured argument resolvers, or possibly null if not initialized yet via afterPropertiesSet().

protected ConfigurableBeanFactory
getBeanFactory()

Return the owning factory of this bean instance, or null if none.

private int
getBodyAdviceCount(Class<?> adviceType)

public List<HandlerMethodArgumentResolver>
getCustomArgumentResolvers()

Return the custom argument resolvers, or null.

public List<HandlerMethodReturnValueHandler>
getCustomReturnValueHandlers()

Return the custom return value handlers, or null.

private WebDataBinderFactory
private List<HandlerMethodArgumentResolver>
getDefaultArgumentResolvers()

Return the list of argument resolvers to use including built-in resolvers and custom resolvers provided via setCustomArgumentResolvers.

private List<HandlerMethodArgumentResolver>
getDefaultInitBinderArgumentResolvers()

Return the list of argument resolvers to use for @InitBinder methods including built-in and custom resolvers.

private List<HandlerMethodReturnValueHandler>
getDefaultReturnValueHandlers()

Return the list of return value handlers to use including built-in and custom handlers provided via setReturnValueHandlers.

public List<HandlerMethodArgumentResolver>
getInitBinderArgumentResolvers()

Return the argument resolvers for @InitBinder methods, or possibly null if not initialized yet via afterPropertiesSet().

protected long
getLastModifiedInternal(HttpServletRequest
current HTTP request
request
,
HandlerMethod
handler method to use
handlerMethod
)

Implements abstract org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.getLastModifiedInternal.

This implementation always returns -1.

public List<HttpMessageConverter<?>>
getMessageConverters()

Return the configured message body converters.

private ModelAndView
getModelAndView(ModelAndViewContainer mavContainer, ModelFactory modelFactory, NativeWebRequest webRequest)

public List<ModelAndViewResolver>
getModelAndViewResolvers()

Return the configured ModelAndViewResolvers, or null.

private ModelFactory
getModelFactory(HandlerMethod handlerMethod, WebDataBinderFactory binderFactory)

public ReactiveAdapterRegistry
getReactiveAdapterRegistry()

Return the configured reactive type registry of adapters.

public List<HandlerMethodReturnValueHandler>
getReturnValueHandlers()

Return the configured handlers, or possibly null if not initialized yet via afterPropertiesSet().

private SessionAttributesHandler
getSessionAttributesHandler(HandlerMethod handlerMethod)

Return the SessionAttributesHandler instance for the given handler type (never null).

public WebBindingInitializer
getWebBindingInitializer()

Return the configured WebBindingInitializer, or null if none.

protected ModelAndView
handleInternal(HttpServletRequest
current HTTP request
request
,
HttpServletResponse
current HTTP response
response
,
HandlerMethod
handler method to use. This object must have previously been passed to the supportsInternal(HandlerMethod) this interface, which must have returned true.
handlerMethod
)

Implements abstract org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handleInternal.

Use the given handler method to handle the request.

private void
private void
protected ModelAndView
invokeHandlerMethod(HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod)

Invoke the RequestMapping handler method preparing a ModelAndView if view resolution is required.

private static Predicate<MethodParameter>
public void
setArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)

Configure the complete list of supported argument types thus overriding the resolvers that would otherwise be configured by default.

public void
setAsyncRequestTimeout(long
the timeout value in milliseconds
timeout
)

Specify the amount of time, in milliseconds, before concurrent handling should time out.

public void
setBeanFactory(BeanFactory
owning BeanFactory (never null). The bean can immediately call methods on the factory.
beanFactory
)

Implements org.springframework.beans.factory.BeanFactoryAware.setBeanFactory.

A ConfigurableBeanFactory is expected for resolving expressions in method argument default values.

public void
setCacheSecondsForSessionAttributeHandlers(int cacheSecondsForSessionAttributeHandlers)

Cache content produced by @SessionAttributes annotated handlers for the given number of seconds.

public void
setCallableInterceptors(List<CallableProcessingInterceptor>
the interceptors to register
interceptors
)

Configure CallableProcessingInterceptor's to register on async requests.

public void
setContentNegotiationManager(ContentNegotiationManager contentNegotiationManager)

Set the ContentNegotiationManager to use to determine requested media types.

public void
setCustomArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)

Provide resolvers for custom argument types.

public void
setCustomReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers)

Provide handlers for custom return value types.

public void
setDeferredResultInterceptors(List<DeferredResultProcessingInterceptor>
the interceptors to register
interceptors
)

Configure DeferredResultProcessingInterceptor's to register on async requests.

public void
setIgnoreDefaultModelOnRedirect(boolean ignoreDefaultModelOnRedirect)
Deprecated since 6.0. as of 6.0 without a replacement; once removed, the default model will always be ignored on redirect

By default, the content of the "default" model is used both during rendering and redirect scenarios.

public void
setInitBinderArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)

Configure the supported argument types in @InitBinder methods.

public void
setMessageConverters(List<HttpMessageConverter<?>> messageConverters)

Provide the converters to use in argument resolvers and return value handlers that support reading and/or writing to the body of the request and response.

public void
public void
setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)

Set the ParameterNameDiscoverer to use for resolving method parameter names if needed (e.g. for default attribute names).

public void
setReactiveAdapterRegistry(ReactiveAdapterRegistry reactiveAdapterRegistry)

Configure the registry for reactive library types to be supported as return values from controller methods.

public void
setRequestBodyAdvice(List<RequestBodyAdvice> requestBodyAdvice)

Add one or more RequestBodyAdvice instances to intercept the request before it is read and converted for @RequestBody and HttpEntity method arguments.

public void
setResponseBodyAdvice(List<ResponseBodyAdvice<?>> responseBodyAdvice)

Add one or more ResponseBodyAdvice instances to intercept the response before @ResponseBody or ResponseEntity return values are written to the response body.

public void
setReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers)

Configure the complete list of supported return value types thus overriding handlers that would otherwise be configured by default.

public void
setSessionAttributeStore(SessionAttributeStore sessionAttributeStore)

Specify the strategy to store session attributes with.

public void
setSynchronizeOnSession(boolean synchronizeOnSession)

Set if controller execution should be synchronized on the session, to serialize parallel invocations from the same client.

public void
setTaskExecutor(AsyncTaskExecutor taskExecutor)

Set the default AsyncTaskExecutor to use when a controller method return a Callable.

public void
setWebBindingInitializer(WebBindingInitializer webBindingInitializer)

Provide a WebBindingInitializer with "global" initialization to apply to every DataBinder instance.

protected boolean
supportsInternal(HandlerMethod
the handler method to check
handlerMethod
)

Implements abstract org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.supportsInternal.

Always return true since any method argument and return value type will be processed in some way.

Inherited from org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter:
getLastModifiedgetOrderhandlesetOrdersupports