一,<interceptor name="chain" class="com.opensymphony.xwork2.interceptor.ChainingInterceptor"/>
就是把这个action的result 转给下个action,那么这个action当中的 valueStack 需要拷贝到下个Action中去
<action name="someAction" class="com.examples.SomeAction"> <interceptor-ref name="basicStack"/> <result name="success" type="chain">otherAction</result> </action> <action name="otherAction" class="com.examples.OtherAction"> <interceptor-ref name="chain"/> <interceptor-ref name="basicStack"/> <result name="success">good_result.ftl</result> </action>
其中可以配置的有struts2的3个常量:
protected Collection<String> excludes; protected Collection<String> includes;
if (exclusions != null && exclusions.contains(fromPd.getName())) { copy = false; } else if (inclusions != null && !inclusions.contains(fromPd.getName())) { copy = false; }
========================================================
二,<interceptor name="cookie" class="org.apache.struts2.interceptor.CookieInterceptor"/>
主要用于将cookie中指定的name 和指定的 value ,放到valueStack中去
如果Action实现了CookieAware接口也可以参考如下代码
/** * Hook that set the <code>cookiesMap</code> into action that implements * {@link CookiesAware}. * * @param action * @param cookiesMap */ protected void injectIntoCookiesAwareAction(Object action, Map<String, String> cookiesMap) { if (action instanceof CookiesAware) { if (LOG.isDebugEnabled()) LOG.debug("action ["+action+"] implements CookiesAware, injecting cookies map ["+cookiesMap+"]"); ((CookiesAware)action).setCookiesMap(cookiesMap); } }