类 DefaultAnnotationHandlerMapping
- java.lang.Object
- org.springframework.context.support.ApplicationObjectSupport
- org.springframework.web.portlet.handler.AbstractHandlerMapping
- org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping<PortletMode>
- org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping
- 所有已实现的接口:
Aware
,ApplicationContextAware
,Ordered
,HandlerMapping
public class DefaultAnnotationHandlerMapping extends AbstractMapBasedHandlerMapping<PortletMode>
Implementation of theHandlerMapping
interface that maps handlers based on portlet modes expressed through theRequestMapping
annotation at the type or method level.Registered by default in
DispatcherPortlet
. NOTE: If you define custom HandlerMapping beans in your DispatcherPortlet 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.portlet.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.NOTE: Method-level mappings are only allowed to narrow the mapping expressed at the class level (if any). A portlet mode in combination with specific parameter conditions needs to uniquely map 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
- 另请参阅:
RequestMapping
,AnnotationMethodHandlerAdapter
嵌套类概要
从类继承的嵌套类/接口 org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping
AbstractMapBasedHandlerMapping.PortletRequestMappingPredicate
字段概要
从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 DefaultAnnotationHandlerMapping()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected boolean
detectHandlerMethods(Class<?> handlerType, String beanName, RequestMapping typeMapping)
Derive portlet mode mappings from the handler's method-level mappings.protected void
detectHandlers()
Register all handlers specified in the Portlet mode map for the corresponding modes.protected PortletMode
getLookupKey(PortletRequest request)
Uses the current PortletMode as lookup key.void
initApplicationContext()
Calls theregisterHandlers
method in addition to the superclass's initialization.从类继承的方法 org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping
getHandlerInternal, registerHandler, registerHandler, registerHandlers, setLazyInitHandlers
从类继承的方法 org.springframework.web.portlet.handler.AbstractHandlerMapping
adaptInterceptor, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getOrder, initInterceptors, setApplyWebRequestInterceptorsToRenderPhaseOnly, setDefaultHandler, setInterceptors, setOrder
从类继承的方法 org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, isContextRequired, requiredContextClass, setApplicationContext
构造器详细资料
DefaultAnnotationHandlerMapping
public DefaultAnnotationHandlerMapping()
方法详细资料
initApplicationContext
public void initApplicationContext() throws BeansException
Calls theregisterHandlers
method in addition to the superclass's initialization.- 覆盖:
initApplicationContext
在类中AbstractHandlerMapping
- 抛出:
ApplicationContextException
- in case of initialization errorsBeansException
- if thrown by ApplicationContext methods- 另请参阅:
detectHandlers()
detectHandlers
protected void detectHandlers() throws BeansException
Register all handlers specified in the Portlet mode map for the corresponding modes.- 抛出:
BeansException
- if the handler couldn't be registered
detectHandlerMethods
protected boolean detectHandlerMethods(Class<?> handlerType, String beanName, RequestMapping typeMapping)
Derive portlet mode mappings from the handler's method-level mappings.- 参数:
handlerType
- the handler type to introspectbeanName
- the name of the bean introspectedtypeMapping
- the type level mapping (if any)- 返回:
true
if at least 1 handler method has been registered;false
otherwise
getLookupKey
protected PortletMode getLookupKey(PortletRequest request) throws Exception
Uses the current PortletMode as lookup key.- 指定者:
getLookupKey
在类中AbstractMapBasedHandlerMapping<PortletMode>
- 参数:
request
- current portlet request- 返回:
- the lookup key (never
null
) - 抛出:
Exception
- if key computation failed