自定义Interceptor后获得Session对象
自定义拦截器的时候 主要分为 三步
1.定义拦截器类 重要的是要继承 AbstractInterceptro 类 重写里面的 intercept(ActionInvocation actionInvocation) 方法
另外注意 其中得到session 对象的方法
ActionContext ac = actionInvocation.getInvocationContext();
Map<String,Object> session = ac .getSession();
2.在struts2 的配置文件中 struts2.xml 文件中声明配置 intercepor
<package name="default" extends="struts-default" namespace="/">
<!--声明拦截器-->
<interceptor name="LoginInterceptor" class="com.ztf.action.UserAction">
<!--在Action中引用拦截器-->
<intercepor-ref>LoginInterceptor</interceptor-ref>
<result name="success">/showUser.jsp</result>
</action>
</package>