struts2 自定义拦截器 无法读取cookie
搞了一天了,怎么就不明白。action可获取,从拦截器跳至其他action都可获取浏览器,就是拦截器里的request的cookie都是空的
sruts2 配置文件
<package name="weixin" namespace="/weixin" extends="struts-default">
<interceptors>
<interceptor name="weixinInterceptor" class="com.jd.pop.wxo2o.web.interceptor.WeixinInterceptor" />
<interceptor-stack name="weixinStack">
<interceptor-ref name="weixinInterceptor"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<action name="*" method="{1}" class="weixinAction">
<result name="gotobind" type="redirect">/bind/bind.action</result>
<interceptor-ref name="weixinStack"/>
</action>
</package>
java 代码
HttpServletRequest request = (HttpServletRequest) actionInvocation.getInvocationContext().get(ServletActionContext.HTTP_REQUEST);
Cookie allCookie[]= request.getCookies();