代码如下:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="user" namespace="/user" extends="struts-default">
<!-- 全局拦截器 -->
<interceptors>
<interceptor name="myIntercept" class="com.ask.intercept.MyIntercept"/>
<interceptor-stack name="mystack">
<interceptor-ref name="myIntercept"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="mystack"></default-interceptor-ref>
<action name="test" class="com.ask.action.UserAction" method="test">
<result name="test">
/WEB-INF/jsp/test.jsp
</result>
<!-- 在这个类中引入全局拦截器 -->
<interceptor-ref name="mystack"></interceptor-ref>
</action>
</package>
</struts>