在自定义拦截器中,您可以定义如下图
private final Map<String, String> interceptorConfigs = new HashMap<String, String>();public Map<String, String> getInterceptorConfigs() { return interceptorConfigs;}public void addInterceptorConfig(final String configName, final String configValue) { interceptorConfigs.put(configName, configValue);}然后,在动作映射中,您可以传递如下参数:这些参数将存储在拦截器的映射中
<action name="yourAction" > <result name="success">some.jsp</result> <interceptor-ref name="defaultStack"> <param name="yourInterceptor.interceptorConfigs.key">value</param> <param name="yourInterceptor.interceptorConfigs.aParamName">paramValue</param> </interceptor-ref> </action>
“ yourInterceptor”是指在将拦截器添加到struts.xml时给定的拦截器的名称。当像上面的“
interceptorConfigs”配置时,拦截器内部的映射将具有,键/值对。
如果您想让这些内容可用于您的操作,只需在中将地图设置为上下文变量即可
ActionContext。然后可以在操作内部检索该信息。



