类 PortletModeParameterHandlerMapping
- java.lang.Object
- org.springframework.context.support.ApplicationObjectSupport
- org.springframework.web.portlet.handler.AbstractHandlerMapping
- org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping<org.springframework.web.portlet.handler.PortletModeParameterLookupKey>
- org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping
- 所有已实现的接口:
Aware
,ApplicationContextAware
,Ordered
,HandlerMapping
public class PortletModeParameterHandlerMapping extends AbstractMapBasedHandlerMapping<org.springframework.web.portlet.handler.PortletModeParameterLookupKey>
Implementation of theHandlerMapping
interface to map from the current PortletMode and a request parameter to request handler beans. The mapping consists of two levels: first the PortletMode and then the parameter value. In order to be mapped, both elements must match the mapping definition.This is a combination of the methods used in
PortletModeHandlerMapping
andParameterHandlerMapping
. Unlike those two classes, this mapping cannot be initialized with properties since it requires a two-level map.The default name of the parameter is "action", but can be changed using
setParameterName()
.By default, the same parameter value may not be used in two different portlet modes. This is so that if the portal itself changes the portlet mode, the request will no longer be valid in the mapping. This behavior can be changed with
setAllowDupParameters()
.The bean configuration for this mapping will look somthing like this:
<bean id="portletModeParameterHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping"> <property name="portletModeParameterMap"> <map> <entry key="view"> <!-- portlet mode: view --> <map> <entry key="add"><ref bean="addItemHandler"/></entry> <entry key="edit"><ref bean="editItemHandler"/></entry> <entry key="delete"><ref bean="deleteItemHandler"/></entry> </map> </entry> <entry key="edit"> <!-- portlet mode: edit --> <map> <entry key="prefs"><ref bean="preferencesHandler"/></entry> <entry key="resetPrefs"><ref bean="resetPreferencesHandler"/></entry> </map> </entry> </map> </property> </bean>
This mapping can be chained ahead of a
PortletModeHandlerMapping
, which can then provide defaults for each mode and an overall default as well.Thanks to Rainer Schmitz and Yujin Kim for suggesting this mapping strategy!
- 从以下版本开始:
- 2.0
- 作者:
- John A. Lewis, Juergen Hoeller
- 另请参阅:
ParameterMappingInterceptor
嵌套类概要
从类继承的嵌套类/接口 org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping
AbstractMapBasedHandlerMapping.PortletRequestMappingPredicate
字段概要
字段 修饰符和类型 字段 说明 static String
DEFAULT_PARAMETER_NAME
Default request parameter name to use for mapping to handlers: "action".从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 PortletModeParameterHandlerMapping()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected org.springframework.web.portlet.handler.PortletModeParameterLookupKey
getLookupKey(PortletRequest request)
Returns a lookup key that combines the current PortletMode and the current value of the specified parameter.void
initApplicationContext()
Calls theregisterHandlers
method in addition to the superclass's initialization.protected void
registerHandler(PortletMode mode, String parameter, Object handler)
Register the given handler instance for the given PortletMode and parameter value, under an appropriate lookup key.protected void
registerHandler(PortletMode mode, Map<String,?> parameterMap)
Register all handlers specified in the given parameter map.protected void
registerHandlersByModeAndParameter(Map<String,Map<String,?>> portletModeParameterMap)
Register all handlers specified in the Portlet mode map for the corresponding modes.void
setAllowDuplicateParameters(boolean allowDuplicateParameters)
Set whether to allow duplicate parameter values across different portlet modes.void
setParameterName(String parameterName)
Set the name of the parameter used for mapping to handlers.void
setPortletModeParameterMap(Map<String,Map<String,?>> portletModeParameterMap)
Set a Map with portlet mode names as keys and another Map as values.从类继承的方法 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
字段详细资料
DEFAULT_PARAMETER_NAME
public static final String DEFAULT_PARAMETER_NAME
Default request parameter name to use for mapping to handlers: "action".- 另请参阅:
- 常量字段值
构造器详细资料
PortletModeParameterHandlerMapping
public PortletModeParameterHandlerMapping()
方法详细资料
setParameterName
public void setParameterName(String parameterName)
Set the name of the parameter used for mapping to handlers.Default is "action".
setPortletModeParameterMap
public void setPortletModeParameterMap(Map<String,Map<String,?>> portletModeParameterMap)
Set a Map with portlet mode names as keys and another Map as values. The sub-map has parameter names as keys and handler bean or bean names as values.Convenient for population with bean references.
- 参数:
portletModeParameterMap
- two-level map of portlet modes and parameters to handler beans
setAllowDuplicateParameters
public void setAllowDuplicateParameters(boolean allowDuplicateParameters)
Set whether to allow duplicate parameter values across different portlet modes. Default is "false".Doing this is dangerous because the portlet mode can be changed by the portal itself and the only way to see that is a rerender of the portlet. If the same parameter value is legal in multiple modes, then a change in mode could result in a matched mapping that is not intended and the user could end up in a strange place in the application.
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- 另请参阅:
AbstractMapBasedHandlerMapping.registerHandlers(java.util.Map<K, ?>)
registerHandlersByModeAndParameter
protected void registerHandlersByModeAndParameter(Map<String,Map<String,?>> portletModeParameterMap)
Register all handlers specified in the Portlet mode map for the corresponding modes.- 参数:
portletModeParameterMap
- Map with mode names as keys and parameter Maps as values
registerHandler
protected void registerHandler(PortletMode mode, Map<String,?> parameterMap)
Register all handlers specified in the given parameter map.- 参数:
parameterMap
- Map with parameter names as keys and handler beans or bean names as values
registerHandler
protected void registerHandler(PortletMode mode, String parameter, Object handler) throws BeansException, IllegalStateException
Register the given handler instance for the given PortletMode and parameter value, under an appropriate lookup key.- 参数:
mode
- the PortletMode for which this mapping is validparameter
- the parameter value to which this handler is mappedhandler
- the handler instance bean- 抛出:
BeansException
- if the handler couldn't be registeredIllegalStateException
- if there is a conflicting handler registered- 另请参阅:
AbstractMapBasedHandlerMapping.registerHandler(Object, Object)
getLookupKey
protected org.springframework.web.portlet.handler.PortletModeParameterLookupKey getLookupKey(PortletRequest request) throws Exception
Returns a lookup key that combines the current PortletMode and the current value of the specified parameter.- 指定者:
getLookupKey
在类中AbstractMapBasedHandlerMapping<org.springframework.web.portlet.handler.PortletModeParameterLookupKey>
- 参数:
request
- current portlet request- 返回:
- the lookup key (never
null
) - 抛出:
Exception
- if key computation failed- 另请参阅:
PortletRequest.getPortletMode()
,setParameterName(java.lang.String)