类 ParameterMappingInterceptor
- java.lang.Object
- org.springframework.web.portlet.handler.HandlerInterceptorAdapter
- org.springframework.web.portlet.handler.ParameterMappingInterceptor
- 所有已实现的接口:
HandlerInterceptor
public class ParameterMappingInterceptor extends HandlerInterceptorAdapter
Interceptor to forward a request parameter from theActionRequest
to theRenderRequest
.This can be useful when using
ParameterHandlerMapping
orPortletModeParameterHandlerMapping
. It will ensure that the parameter that was used to map theActionRequest
to a handler will be forwarded to theRenderRequest
so that it will also be mapped the same way.When using this Interceptor, you can still change the value of the mapping parameter in your handler in order to change where the render request will get mapped.
Be aware that this Interceptor does call
ActionResponse.setRenderParameter
, which means that you will not be able to callActionResponse.sendRedirect
in your handler. If you may need to issue a redirect, then you should avoid this Interceptor and either write a different one that does this in a different way, or manually forward the parameter from within your handler(s).Thanks to Rainer Schmitz for suggesting this mapping strategy!
- 从以下版本开始:
- 2.0
- 作者:
- John A. Lewis
- 另请参阅:
ParameterHandlerMapping
,PortletModeParameterHandlerMapping
字段概要
字段 修饰符和类型 字段 说明 static String
DEFAULT_PARAMETER_NAME
Request parameter name to use for mapping to handlers
构造器概要
构造器 构造器 说明 ParameterMappingInterceptor()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 boolean
preHandleAction(ActionRequest request, ActionResponse response, Object handler)
If request is anActionRequest
, get handler mapping parameter and add it to the ActionResponse.void
setParameterName(String parameterName)
Set the name of the parameter used for mapping.从类继承的方法 org.springframework.web.portlet.handler.HandlerInterceptorAdapter
afterActionCompletion, afterCompletion, afterEventCompletion, afterRenderCompletion, afterResourceCompletion, postHandleRender, postHandleResource, preHandle, preHandleEvent, preHandleRender, preHandleResource
字段详细资料
DEFAULT_PARAMETER_NAME
public static final String DEFAULT_PARAMETER_NAME
Request parameter name to use for mapping to handlers- 另请参阅:
- 常量字段值
构造器详细资料
ParameterMappingInterceptor
public ParameterMappingInterceptor()
方法详细资料
setParameterName
public void setParameterName(String parameterName)
Set the name of the parameter used for mapping.
preHandleAction
public boolean preHandleAction(ActionRequest request, ActionResponse response, Object handler)
If request is anActionRequest
, get handler mapping parameter and add it to the ActionResponse.- 指定者:
preHandleAction
在接口中HandlerInterceptor
- 覆盖:
preHandleAction
在类中HandlerInterceptorAdapter
- 参数:
request
- current portlet action requestresponse
- current portlet action responsehandler
- chosen handler to execute, for type and/or instance evaluation- 返回:
true
if the execution chain should proceed with the next interceptor or the handler itself. Else,DispatcherPortlet
assumes that this interceptor has already dealt with the response itself