public class ParameterHandlerMapping extends AbstractMapBasedHandlerMapping<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 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 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(Map<String,?> parameterMap)
Set a Map with parameters as keys and handler beans or bean names as values.
|
void |
setParameterName(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 String DEFAULT_PARAMETER_NAME
public void setParameterName(String parameterName)
Default is "action".
public void setParameterMap(Map<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 String getLookupKey(PortletRequest request) throws Exception
getLookupKey
in class AbstractMapBasedHandlerMapping<String>
request
- current portlet requestnull
)Exception
- if key computation failedsetParameterName(java.lang.String)