java.lang.Object | ||||
↳ | org.springframework.context.support.ApplicationObjectSupport | |||
↳ | org.springframework.web.context.support.WebApplicationObjectSupport | |||
↳ | org.springframework.web.servlet.support.WebContentGenerator | |||
↳ | org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter |
Implementation of the HandlerAdapter
interface
that maps handler methods based on HTTP paths, HTTP methods and request parameters
expressed through the RequestMapping
annotation.
Supports request parameter binding through the RequestParam
annotation.
Also supports the ModelAttribute
annotation for exposing model attribute
values to the view, as well as InitBinder
for binder initialization methods
and SessionAttributes
for automatic session management of specific attributes.
This adapter can be customized through various bean properties.
A common use case is to apply shared binder initialization logic through
a custom WebBindingInitializer
.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | PAGE_NOT_FOUND_LOG_CATEGORY | Log category to use when no mapped handler is found for a request. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.web.servlet.support.WebContentGenerator
| |||||||||||
From interface
org.springframework.core.Ordered
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
pageNotFoundLogger | Additional logger to use when no mapped handler is found for a request. |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.context.support.ApplicationObjectSupport
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Same contract as for HttpServlet's
getLastModified method. | |||||||||||
Return the message body converters that this adapter has been configured with.
| |||||||||||
Return the order value of this object, with a
higher value meaning greater in terms of sorting.
| |||||||||||
Use the given handler to handle this request.
| |||||||||||
Set if URL lookup should always use the full path within the current servlet
context.
| |||||||||||
Callback that supplies the owning factory to a bean instance.
| |||||||||||
Cache content produced by
@SessionAttributes annotated handlers
for the given number of seconds. | |||||||||||
Set a custom WebArgumentResolvers to use for special method parameter types.
| |||||||||||
Set one or more custom WebArgumentResolvers to use for special method parameter types.
| |||||||||||
Set a custom ModelAndViewResolvers to use for special method return types.
| |||||||||||
Set one or more custom ModelAndViewResolvers to use for special method return types.
| |||||||||||
Set the message body converters to use.
| |||||||||||
Set the MethodNameResolver to use for resolving default handler methods
(carrying an empty
@RequestMapping annotation). | |||||||||||
Specify the order value for this HandlerAdapter bean.
| |||||||||||
Set the ParameterNameDiscoverer to use for resolving method parameter names if needed
(e.g.
| |||||||||||
Set the PathMatcher implementation to use for matching URL paths against registered URL patterns.
| |||||||||||
Specify the strategy to store session attributes with.
| |||||||||||
Set if controller execution should be synchronized on the session,
to serialize parallel invocations from the same client.
| |||||||||||
Set if context path and request URI should be URL-decoded.
| |||||||||||
Set the UrlPathHelper to use for resolution of lookup paths.
| |||||||||||
Specify a WebBindingInitializer which will apply pre-configured
configuration to every DataBinder that this controller uses.
| |||||||||||
Given a handler instance, return whether or not this HandlerAdapter can
support it.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Template method for creating a new ServletRequestDataBinder instance.
| |||||||||||
Template method for creating a new HttpInputMessage instance.
| |||||||||||
Template method for creating a new HttpOuputMessage instance.
| |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.web.servlet.support.WebContentGenerator
| |||||||||||
From class
org.springframework.web.context.support.WebApplicationObjectSupport
| |||||||||||
From class
org.springframework.context.support.ApplicationObjectSupport
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.BeanFactoryAware
| |||||||||||
From interface
org.springframework.context.ApplicationContextAware
| |||||||||||
From interface
org.springframework.core.Ordered
| |||||||||||
From interface
org.springframework.web.context.ServletContextAware
| |||||||||||
From interface
org.springframework.web.servlet.HandlerAdapter
|
Log category to use when no mapped handler is found for a request.
Additional logger to use when no mapped handler is found for a request.
Same contract as for HttpServlet's getLastModified
method.
Can simply return -1 if there's no support in the handler class.
request | current HTTP request |
---|---|
handler | handler to use |
Return the message body converters that this adapter has been configured with.
Return the order value of this object, with a higher value meaning greater in terms of sorting.
Normally starting with 0, with Integer.MAX_VALUE
indicating the greatest value. Same order values will result
in arbitrary positions for the affected objects.
Higher values can be interpreted as lower priority. As a consequence, the object with the lowest value has highest priority (somewhat analogous to Servlet "load-on-startup" values).
Use the given handler to handle this request. The workflow that is required may vary widely.
request | current HTTP request |
---|---|
response | current HTTP response |
handler | handler to use. This object must have previously been passed
to the supports method of this interface, which must have
returned true . |
null
if the request has been handled directly
Exception |
---|
Set if URL lookup should always use the full path within the current servlet context. Else, the path within the current servlet mapping is used if applicable (that is, in the case of a ".../*" servlet mapping in web.xml).
Default is "false".
Callback that supplies the owning factory to a bean instance.
Invoked after the population of normal bean properties
but before an initialization callback such as
afterPropertiesSet()
or a custom init-method.
beanFactory | owning BeanFactory (never null ).
The bean can immediately call methods on the factory. |
---|
Cache content produced by @SessionAttributes
annotated handlers
for the given number of seconds. Default is 0, preventing caching completely.
In contrast to the "cacheSeconds" property which will apply to all general handlers
(but not to @SessionAttributes
annotated handlers), this setting will
apply to @SessionAttributes
annotated handlers only.
Set a custom WebArgumentResolvers to use for special method parameter types.
Such a custom WebArgumentResolver will kick in first, having a chance to resolve an argument value before the standard argument handling kicks in.
Set one or more custom WebArgumentResolvers to use for special method parameter types.
Any such custom WebArgumentResolver will kick in first, having a chance to resolve an argument value before the standard argument handling kicks in.
Set a custom ModelAndViewResolvers to use for special method return types.
Such a custom ModelAndViewResolver will kick in first, having a chance to resolve a return value before the standard ModelAndView handling kicks in.
Set one or more custom ModelAndViewResolvers to use for special method return types.
Any such custom ModelAndViewResolver will kick in first, having a chance to resolve a return value before the standard ModelAndView handling kicks in.
Set the message body converters to use.
These converters are used to convert from and to HTTP requests and responses.
Set the MethodNameResolver to use for resolving default handler methods
(carrying an empty @RequestMapping
annotation).
Will only kick in when the handler method cannot be resolved uniquely through the annotation metadata already.
Specify the order value for this HandlerAdapter bean.
Default value is Integer.MAX_VALUE
, meaning that it's non-ordered.
Set the ParameterNameDiscoverer to use for resolving method parameter names if needed (e.g. for default attribute names).
Default is a LocalVariableTableParameterNameDiscoverer
.
Set the PathMatcher implementation to use for matching URL paths against registered URL patterns.
Default is AntPathMatcher
.
Specify the strategy to store session attributes with.
Default is DefaultSessionAttributeStore
,
storing session attributes in the HttpSession, using the same attribute name as in the model.
Set if controller execution should be synchronized on the session, to serialize parallel invocations from the same client.
More specifically, the execution of the handleRequestInternal
method will get synchronized if this flag is "true". The best available
session mutex will be used for the synchronization; ideally, this will
be a mutex exposed by HttpSessionMutexListener.
The session mutex is guaranteed to be the same object during
the entire lifetime of the session, available under the key defined
by the SESSION_MUTEX_ATTRIBUTE
constant. It serves as a
safe reference to synchronize on for locking on the current session.
In many cases, the HttpSession reference itself is a safe mutex as well, since it will always be the same object reference for the same active logical session. However, this is not guaranteed across different servlet containers; the only 100% safe way is a session mutex.
Set if context path and request URI should be URL-decoded. Both are returned undecoded by the Servlet API, in contrast to the servlet path.
Uses either the request encoding or the default encoding according to the Servlet spec (ISO-8859-1).
Set the UrlPathHelper to use for resolution of lookup paths.
Use this to override the default UrlPathHelper with a custom subclass, or to share common UrlPathHelper settings across multiple HandlerMappings and HandlerAdapters.
Specify a WebBindingInitializer which will apply pre-configured configuration to every DataBinder that this controller uses.
Given a handler instance, return whether or not this HandlerAdapter can support it. Typical HandlerAdapters will base the decision on the handler type. HandlerAdapters will usually only support one handler type each.
A typical implementation:
return (handler instanceof MyHandler);
handler | handler object to check |
---|
Template method for creating a new ServletRequestDataBinder instance.
The default implementation creates a standard ServletRequestDataBinder. This can be overridden for custom ServletRequestDataBinder subclasses.
request | current HTTP request |
---|---|
target | the target object to bind onto (or null
if the binder is just used to convert a plain parameter value) |
objectName | the objectName of the target object |
Exception | in case of invalid state or arguments |
---|
Template method for creating a new HttpInputMessage instance.
The default implementation creates a standard ServletServerHttpRequest
.
This can be overridden for custom HttpInputMessage
implementations
servletRequest | current HTTP request |
---|
Exception | in case of errors |
---|
Template method for creating a new HttpOuputMessage instance.
The default implementation creates a standard ServletServerHttpResponse
.
This can be overridden for custom HttpOutputMessage
implementations
servletResponse | current HTTP response |
---|
Exception | in case of errors |
---|
Exception |
---|