Struts2- 设置默认拦截器

时间:2022-01-08 16:12:20
<?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="default" namespace="/" extends="struts-default">
<interceptors>
<interceptor name="LoginInterceptor" class="com.gordon.interceptor.LoginInterceptor">
<param name="excludeMethods">login,register</param>
</interceptor> <interceptor-stack name="myStack">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="LoginInterceptor"/>
</interceptor-stack>
</interceptors> <!-- 设置默认拦截器 -->
<default-interceptor-ref name="myStack"/> <global-results>
<result name="login" type="redirect">/login.jsp</result>
</global-results> <action name="login_*" class="com.gordon.action.LoginAction" method="{1}">
<result name="success" type="redirect">/success.jsp</result>
</action> <action name="user_*" class="com.gordon.action.UserAction" method="{1}">
<result name="success" type="redirect">/main.jsp</result>
</action>
</package>
</struts>