类 DefaultAnnotationHandlerMapping
- java.lang.Object
- org.springframework.context.support.ApplicationObjectSupport
- org.springframework.web.context.support.WebApplicationObjectSupport
- org.springframework.web.servlet.handler.AbstractHandlerMapping
- org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
- org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping
- org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping
- 所有已实现的接口:
Aware
,ApplicationContextAware
,Ordered
,ServletContextAware
,MatchableHandlerMapping
,HandlerMapping
@Deprecated public class DefaultAnnotationHandlerMapping extends AbstractDetectingUrlHandlerMapping
已过时。as of Spring 3.2, in favor ofRequestMappingHandlerMapping
Implementation of theHandlerMapping
interface that maps handlers based on HTTP paths expressed through theRequestMapping
annotation at the type or method level.Registered by default in
DispatcherServlet
on Java 5+. NOTE: If you define custom HandlerMapping beans in your DispatcherServlet context, you need to add a DefaultAnnotationHandlerMapping bean explicitly, since custom HandlerMapping beans replace the default mapping strategies. Defining a DefaultAnnotationHandlerMapping also allows for registering custom interceptors:<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> <property name="interceptors"> ... </property> </bean>
Annotated controllers are usually marked with theController
stereotype at the type level. This is not strictly necessary whenRequestMapping
is applied at the type level (since such a handler usually implements theController
interface). However,Controller
is required for detectingRequestMapping
annotations at the method level ifRequestMapping
is not present at the type level.NOTE: Method-level mappings are only allowed to narrow the mapping expressed at the class level (if any). HTTP paths need to uniquely map onto specific handler beans, with any given HTTP path only allowed to be mapped onto one specific handler bean (not spread across multiple handler beans). It is strongly recommended to co-locate related handler methods into the same bean.
The
AnnotationMethodHandlerAdapter
is responsible for processing annotated handler methods, as mapped by this HandlerMapping. ForRequestMapping
at the type level, specific HandlerAdapters such asSimpleControllerHandlerAdapter
apply.- 从以下版本开始:
- 2.5
- 作者:
- Juergen Hoeller, Arjen Poutsma
- 另请参阅:
RequestMapping
,AnnotationMethodHandlerAdapter
字段概要
从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger
从接口继承的字段 org.springframework.web.servlet.HandlerMapping
BEST_MATCHING_HANDLER_ATTRIBUTE, BEST_MATCHING_PATTERN_ATTRIBUTE, INTROSPECT_TYPE_LEVEL_MAPPING, MATRIX_VARIABLES_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 DefaultAnnotationHandlerMapping()
已过时。
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 protected void
addUrlsForPath(Set<String> urls, String path)
已过时。Add URLs and/or URL patterns for the given path.protected String[]
determineUrlsForHandler(String beanName)
已过时。Checks for presence of theRequestMapping
annotation on the handler class and on any of its methods.protected String[]
determineUrlsForHandlerMethods(Class<?> handlerType)
已过时。Derive URL mappings from the handler's method-level mappings.protected String[]
determineUrlsForHandlerMethods(Class<?> handlerType, boolean hasTypeLevelMapping)
已过时。Derive URL mappings from the handler's method-level mappings.void
setUseDefaultSuffixPattern(boolean useDefaultSuffixPattern)
已过时。Set whether to register paths using the default suffix pattern as well: i.e. whether "/users" should be registered as "/users.*" and "/users/" too.protected boolean
supportsTypeLevelMappings()
已过时。Indicates whether this handler mapping support type-level mappings.protected void
validateHandler(Object handler, HttpServletRequest request)
已过时。Validate the given annotated handler against the current request.protected void
validateMapping(RequestMapping mapping, HttpServletRequest request)
已过时。Validate the given type-level mapping metadata against the current request, checking HTTP request method and parameter conditions.从类继承的方法 org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping
detectHandlers, initApplicationContext, setDetectHandlersInAncestorContexts
从类继承的方法 org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
buildPathExposingHandler, exposePathWithinMapping, exposeUriTemplateVariables, getHandlerInternal, getHandlerMap, getRootHandler, lookupHandler, match, registerHandler, registerHandler, setLazyInitHandlers, setRootHandler, setUseTrailingSlashMatch, useTrailingSlashMatch
从类继承的方法 org.springframework.web.servlet.handler.AbstractHandlerMapping
adaptInterceptor, detectMappedInterceptors, extendInterceptors, getAdaptedInterceptors, getCorsConfiguration, getCorsConfigurations, getCorsHandlerExecutionChain, getCorsProcessor, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getUrlPathHelper, initInterceptors, setAlwaysUseFullPath, setCorsConfigurations, setCorsProcessor, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setRemoveSemicolonContent, setUrlDecode, setUrlPathHelper
从类继承的方法 org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
从类继承的方法 org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.web.servlet.HandlerMapping
getHandler
构造器详细资料
DefaultAnnotationHandlerMapping
public DefaultAnnotationHandlerMapping()
已过时。
方法详细资料
setUseDefaultSuffixPattern
public void setUseDefaultSuffixPattern(boolean useDefaultSuffixPattern)
已过时。Set whether to register paths using the default suffix pattern as well: i.e. whether "/users" should be registered as "/users.*" and "/users/" too.Default is "true". Turn this convention off if you intend to interpret your
@RequestMapping
paths strictly.Note that paths which include a ".xxx" suffix or end with "/" already will not be transformed using the default suffix pattern in any case.
determineUrlsForHandler
protected String[] determineUrlsForHandler(String beanName)
已过时。Checks for presence of theRequestMapping
annotation on the handler class and on any of its methods.- 指定者:
determineUrlsForHandler
在类中AbstractDetectingUrlHandlerMapping
- 参数:
beanName
- the name of the candidate bean- 返回:
- the URLs determined for the bean, or
null
or an empty array if none
determineUrlsForHandlerMethods
protected String[] determineUrlsForHandlerMethods(Class<?> handlerType, boolean hasTypeLevelMapping)
已过时。Derive URL mappings from the handler's method-level mappings.- 参数:
handlerType
- the handler type to introspecthasTypeLevelMapping
- whether the method-level mappings are nested within a type-level mapping- 返回:
- the array of mapped URLs
determineUrlsForHandlerMethods
protected String[] determineUrlsForHandlerMethods(Class<?> handlerType)
已过时。Derive URL mappings from the handler's method-level mappings.- 参数:
handlerType
- the handler type to introspect- 返回:
- the array of mapped URLs
addUrlsForPath
protected void addUrlsForPath(Set<String> urls, String path)
已过时。Add URLs and/or URL patterns for the given path.- 参数:
urls
- the Set of URLs for the current beanpath
- the currently introspected path
validateHandler
protected void validateHandler(Object handler, HttpServletRequest request) throws Exception
已过时。Validate the given annotated handler against the current request.- 覆盖:
validateHandler
在类中AbstractUrlHandlerMapping
- 参数:
handler
- the handler object to validaterequest
- current HTTP request- 抛出:
Exception
- if validation failed- 另请参阅:
validateMapping(org.springframework.web.bind.annotation.RequestMapping, javax.servlet.http.HttpServletRequest)
validateMapping
protected void validateMapping(RequestMapping mapping, HttpServletRequest request) throws Exception
已过时。Validate the given type-level mapping metadata against the current request, checking HTTP request method and parameter conditions.- 参数:
mapping
- the mapping metadata to validaterequest
- current HTTP request- 抛出:
Exception
- if validation failed
supportsTypeLevelMappings
protected boolean supportsTypeLevelMappings()
已过时。从类复制的说明:AbstractUrlHandlerMapping
Indicates whether this handler mapping support type-level mappings. Default tofalse
.