public class ParameterHandlerMapping extends AbstractMapBasedHandlerMapping<java.lang.String>
HandlerMapping
to map from a request parameter to request handler beans.
The default name of the parameter is "action", but can be changed using
setParameterName()
.
The bean configuration for this mapping will look somthing like this:
<bean id="parameterHandlerMapping" class="org.springframework.web.portlet.handler.ParameterHandlerMapping"> <property name="parameterMap"> <map> <entry key="add"><ref bean="addItemHandler"/></entry> <entry key="edit"><ref bean="editItemHandler"/></entry> <entry key="delete"><ref bean="deleteItemHandler"/></entry> </map> </property> </bean>Thanks to Rainer Schmitz for suggesting this mapping strategy!
ParameterMappingInterceptor
AbstractMapBasedHandlerMapping.PortletRequestMappingPredicate
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_PARAMETER_NAME
Default request parameter name to use for mapping to handlers: "action".
|
logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
ParameterHandlerMapping() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
getLookupKey(PortletRequest request)
Uses the value of the specified parameter as lookup key.
|
void |
initApplicationContext()
Calls the
registerHandlers method in addition
to the superclass's initialization. |
void |
setParameterMap(java.util.Map<java.lang.String,?> parameterMap)
Set a Map with parameters as keys and handler beans or bean names as values.
|
void |
setParameterName(java.lang.String parameterName)
Set the name of the parameter used for mapping to handlers.
|
getHandlerInternal, registerHandler, registerHandler, registerHandlers, setLazyInitHandlers
adaptInterceptor, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getOrder, initInterceptors, setApplyWebRequestInterceptorsToRenderPhaseOnly, setDefaultHandler, setInterceptors, setOrder
getApplicationContext, getMessageSourceAccessor, initApplicationContext, isContextRequired, requiredContextClass, setApplicationContext
public static final java.lang.String DEFAULT_PARAMETER_NAME
public void setParameterName(java.lang.String parameterName)
Default is "action".
public void setParameterMap(java.util.Map<java.lang.String,?> parameterMap)
parameterMap
- map with parameters as keys and beans as valuespublic void initApplicationContext() throws BeansException
registerHandlers
method in addition
to the superclass's initialization.initApplicationContext
in class AbstractHandlerMapping
ApplicationContextException
- in case of initialization errorsBeansException
- if thrown by ApplicationContext methodsAbstractMapBasedHandlerMapping.registerHandlers(java.util.Map<K, ?>)
protected java.lang.String getLookupKey(PortletRequest request) throws java.lang.Exception
getLookupKey
in class AbstractMapBasedHandlerMapping<java.lang.String>
request
- current portlet requestnull
)java.lang.Exception
- if key computation failedsetParameterName(java.lang.String)