类 AnnotationMethodHandlerAdapter
- 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
- 所有已实现的接口:
Aware
,BeanFactoryAware
,ApplicationContextAware
,Ordered
,ServletContextAware
,HandlerAdapter
@Deprecated public class AnnotationMethodHandlerAdapter extends WebContentGenerator implements HandlerAdapter, Ordered, BeanFactoryAware
已过时。as of Spring 3.2, in favor ofRequestMappingHandlerAdapter
Implementation of theHandlerAdapter
interface that maps handler methods based on HTTP paths, HTTP methods, and request parameters expressed through theRequestMapping
annotation.Supports request parameter binding through the
RequestParam
annotation. Also supports theModelAttribute
annotation for exposing model attribute values to the view, as well asInitBinder
for binder initialization methods andSessionAttributes
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
.- 从以下版本开始:
- 2.5
- 作者:
- Juergen Hoeller, Arjen Poutsma, Sam Brannen
- 另请参阅:
setPathMatcher(org.springframework.util.PathMatcher)
,setMethodNameResolver(org.springframework.web.servlet.mvc.multiaction.MethodNameResolver)
,setWebBindingInitializer(org.springframework.web.bind.support.WebBindingInitializer)
,setSessionAttributeStore(org.springframework.web.bind.support.SessionAttributeStore)
字段概要
字段 修饰符和类型 字段 说明 static String
PAGE_NOT_FOUND_LOG_CATEGORY
已过时。Log category to use when no mapped handler is found for a request.protected static Log
pageNotFoundLogger
已过时。Additional logger to use when no mapped handler is found for a request.从类继承的字段 org.springframework.web.servlet.support.WebContentGenerator
HEADER_CACHE_CONTROL, METHOD_GET, METHOD_HEAD, METHOD_POST
从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 AnnotationMethodHandlerAdapter()
已过时。
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 protected ServletRequestDataBinder
createBinder(HttpServletRequest request, Object target, String objectName)
已过时。Template method for creating a new ServletRequestDataBinder instance.protected HttpInputMessage
createHttpInputMessage(HttpServletRequest servletRequest)
已过时。Template method for creating a new HttpInputMessage instance.protected HttpOutputMessage
createHttpOutputMessage(HttpServletResponse servletResponse)
已过时。Template method for creating a new HttpOutputMessage instance.long
getLastModified(HttpServletRequest request, Object handler)
已过时。This method always returns -1 since an annotated controller can have many methods, each requiring separate lastModified calculations.HttpMessageConverter<?>[]
getMessageConverters()
已过时。Return the message body converters that this adapter has been configured with.int
getOrder()
已过时。Get the order value of this object.ModelAndView
handle(HttpServletRequest request, HttpServletResponse response, Object handler)
已过时。Use the given handler to handle this request.protected ModelAndView
invokeHandlerMethod(HttpServletRequest request, HttpServletResponse response, Object handler)
已过时。void
setAlwaysUseFullPath(boolean alwaysUseFullPath)
已过时。Set if URL lookup should always use the full path within the current servlet context.void
setBeanFactory(BeanFactory beanFactory)
已过时。Callback that supplies the owning factory to a bean instance.void
setCacheSecondsForSessionAttributeHandlers(int cacheSecondsForSessionAttributeHandlers)
已过时。Cache content produced by@SessionAttributes
annotated handlers for the given number of seconds.void
setCustomArgumentResolver(WebArgumentResolver argumentResolver)
已过时。Set a custom WebArgumentResolvers to use for special method parameter types.void
setCustomArgumentResolvers(WebArgumentResolver... argumentResolvers)
已过时。Set one or more custom WebArgumentResolvers to use for special method parameter types.void
setCustomModelAndViewResolver(ModelAndViewResolver customModelAndViewResolver)
已过时。Set a custom ModelAndViewResolvers to use for special method return types.void
setCustomModelAndViewResolvers(ModelAndViewResolver... customModelAndViewResolvers)
已过时。Set one or more custom ModelAndViewResolvers to use for special method return types.void
setMessageConverters(HttpMessageConverter<?>[] messageConverters)
已过时。Set the message body converters to use.void
setMethodNameResolver(MethodNameResolver methodNameResolver)
已过时。Set the MethodNameResolver to use for resolving default handler methods (carrying an empty@RequestMapping
annotation).void
setOrder(int order)
已过时。Specify the order value for this HandlerAdapter bean.void
setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)
已过时。Set the ParameterNameDiscoverer to use for resolving method parameter names if needed (e.g. for default attribute names).void
setPathMatcher(PathMatcher pathMatcher)
已过时。Set the PathMatcher implementation to use for matching URL paths against registered URL patterns.void
setSessionAttributeStore(SessionAttributeStore sessionAttributeStore)
已过时。Specify the strategy to store session attributes with.void
setSynchronizeOnSession(boolean synchronizeOnSession)
已过时。Set if controller execution should be synchronized on the session, to serialize parallel invocations from the same client.void
setUrlDecode(boolean urlDecode)
已过时。Set if context path and request URI should be URL-decoded.void
setUrlPathHelper(UrlPathHelper urlPathHelper)
已过时。Set the UrlPathHelper to use for resolution of lookup paths.void
setWebBindingInitializer(WebBindingInitializer webBindingInitializer)
已过时。Specify a WebBindingInitializer which will apply pre-configured configuration to every DataBinder that this controller uses.boolean
supports(Object handler)
已过时。Given a handler instance, return whether or not thisHandlerAdapter
can support it.从类继承的方法 org.springframework.web.servlet.support.WebContentGenerator
applyCacheControl, applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, checkRequest, getAllowHeader, getCacheControl, getCacheSeconds, getSupportedMethods, getVaryByRequestHeaders, isAlwaysMustRevalidate, isRequireSession, isUseCacheControlHeader, isUseCacheControlNoStore, isUseExpiresHeader, prepareResponse, preventCaching, setAlwaysMustRevalidate, setCacheControl, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseCacheControlNoStore, setUseExpiresHeader, setVaryByRequestHeaders
从类继承的方法 org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
从类继承的方法 org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
字段详细资料
PAGE_NOT_FOUND_LOG_CATEGORY
public static final String PAGE_NOT_FOUND_LOG_CATEGORY
已过时。Log category to use when no mapped handler is found for a request.- 另请参阅:
pageNotFoundLogger
, 常量字段值
pageNotFoundLogger
protected static final Log pageNotFoundLogger
已过时。Additional logger to use when no mapped handler is found for a request.
构造器详细资料
AnnotationMethodHandlerAdapter
public AnnotationMethodHandlerAdapter()
已过时。
方法详细资料
setAlwaysUseFullPath
public void setAlwaysUseFullPath(boolean alwaysUseFullPath)
已过时。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".
setUrlDecode
public void setUrlDecode(boolean urlDecode)
已过时。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).
setUrlPathHelper
public void setUrlPathHelper(UrlPathHelper urlPathHelper)
已过时。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.
setPathMatcher
public void setPathMatcher(PathMatcher pathMatcher)
已过时。Set the PathMatcher implementation to use for matching URL paths against registered URL patterns.Default is
AntPathMatcher
.
setMethodNameResolver
public void setMethodNameResolver(MethodNameResolver methodNameResolver)
已过时。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.
setWebBindingInitializer
public void setWebBindingInitializer(WebBindingInitializer webBindingInitializer)
已过时。Specify a WebBindingInitializer which will apply pre-configured configuration to every DataBinder that this controller uses.
setSessionAttributeStore
public void setSessionAttributeStore(SessionAttributeStore sessionAttributeStore)
已过时。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.
setCacheSecondsForSessionAttributeHandlers
public void setCacheSecondsForSessionAttributeHandlers(int cacheSecondsForSessionAttributeHandlers)
已过时。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.
setSynchronizeOnSession
public void setSynchronizeOnSession(boolean synchronizeOnSession)
已过时。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.
setParameterNameDiscoverer
public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)
已过时。Set the ParameterNameDiscoverer to use for resolving method parameter names if needed (e.g. for default attribute names).Default is a
DefaultParameterNameDiscoverer
.
setCustomArgumentResolver
public void setCustomArgumentResolver(WebArgumentResolver argumentResolver)
已过时。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.
setCustomArgumentResolvers
public void setCustomArgumentResolvers(WebArgumentResolver... argumentResolvers)
已过时。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.
setCustomModelAndViewResolver
public void setCustomModelAndViewResolver(ModelAndViewResolver customModelAndViewResolver)
已过时。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.
setCustomModelAndViewResolvers
public void setCustomModelAndViewResolvers(ModelAndViewResolver... customModelAndViewResolvers)
已过时。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.
setMessageConverters
public void setMessageConverters(HttpMessageConverter<?>[] messageConverters)
已过时。Set the message body converters to use.These converters are used to convert from and to HTTP requests and responses.
getMessageConverters
public HttpMessageConverter<?>[] getMessageConverters()
已过时。Return the message body converters that this adapter has been configured with.
setOrder
public void setOrder(int order)
已过时。Specify the order value for this HandlerAdapter bean.Default value is
Integer.MAX_VALUE
, meaning that it's non-ordered.- 另请参阅:
Ordered.getOrder()
getOrder
public int getOrder()
已过时。从接口复制的说明:Ordered
Get the order value of this object.Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority (somewhat analogous to Servlet
load-on-startup
values).Same order values will result in arbitrary sort positions for the affected objects.
- 指定者:
getOrder
在接口中Ordered
- 返回:
- the order value
- 另请参阅:
Ordered.HIGHEST_PRECEDENCE
,Ordered.LOWEST_PRECEDENCE
setBeanFactory
public void setBeanFactory(BeanFactory beanFactory)
已过时。从接口复制的说明:BeanFactoryAware
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
InitializingBean.afterPropertiesSet()
or a custom init-method.- 指定者:
setBeanFactory
在接口中BeanFactoryAware
- 参数:
beanFactory
- owning BeanFactory (nevernull
). The bean can immediately call methods on the factory.- 另请参阅:
BeanInitializationException
supports
public boolean supports(Object handler)
已过时。从接口复制的说明:HandlerAdapter
Given a handler instance, return whether or not thisHandlerAdapter
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);
- 指定者:
supports
在接口中HandlerAdapter
- 参数:
handler
- handler object to check- 返回:
- whether or not this object can use the given handler
handle
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
已过时。从接口复制的说明:HandlerAdapter
Use the given handler to handle this request. The workflow that is required may vary widely.- 指定者:
handle
在接口中HandlerAdapter
- 参数:
request
- current HTTP requestresponse
- current HTTP responsehandler
- handler to use. This object must have previously been passed to thesupports
method of this interface, which must have returnedtrue
.- 返回:
- ModelAndView object with the name of the view and the required model data, or
null
if the request has been handled directly - 抛出:
Exception
- in case of errors
invokeHandlerMethod
protected ModelAndView invokeHandlerMethod(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
已过时。- 抛出:
Exception
getLastModified
public long getLastModified(HttpServletRequest request, Object handler)
已过时。This method always returns -1 since an annotated controller can have many methods, each requiring separate lastModified calculations. Instead, anRequestMapping
-annotated method can calculate the lastModified value, callWebRequest.checkNotModified(long)
to check it, and returnnull
if that returnstrue
.- 指定者:
getLastModified
在接口中HandlerAdapter
- 参数:
request
- current HTTP requesthandler
- handler to use- 返回:
- the lastModified value for the given handler
- 另请参阅:
WebRequest.checkNotModified(long)
createBinder
protected ServletRequestDataBinder createBinder(HttpServletRequest request, Object target, String objectName) throws Exception
已过时。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 requesttarget
- the target object to bind onto (ornull
if the binder is just used to convert a plain parameter value)objectName
- the objectName of the target object- 返回:
- the ServletRequestDataBinder instance to use
- 抛出:
Exception
- in case of invalid state or arguments- 另请参阅:
ServletRequestDataBinder.bind(javax.servlet.ServletRequest)
,DataBinder.convertIfNecessary(Object, Class, org.springframework.core.MethodParameter)
createHttpInputMessage
protected HttpInputMessage createHttpInputMessage(HttpServletRequest servletRequest) throws Exception
已过时。Template method for creating a new HttpInputMessage instance.The default implementation creates a standard
ServletServerHttpRequest
. This can be overridden for customHttpInputMessage
implementations- 参数:
servletRequest
- current HTTP request- 返回:
- the HttpInputMessage instance to use
- 抛出:
Exception
- in case of errors
createHttpOutputMessage
protected HttpOutputMessage createHttpOutputMessage(HttpServletResponse servletResponse) throws Exception
已过时。Template method for creating a new HttpOutputMessage instance.The default implementation creates a standard
ServletServerHttpResponse
. This can be overridden for customHttpOutputMessage
implementations- 参数:
servletResponse
- current HTTP response- 返回:
- the HttpInputMessage instance to use
- 抛出:
Exception
- in case of errors