<?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>
<constant name="struts.devMode" value="true"></constant>
<package name="my" extends="struts-default">
<interceptors>
<interceptor name="demo1Interceptor" class="com.sanmao.interceptors.Demo1Interceptor"></interceptor>
<interceptor name="costTimeInterceptor" class="com.sanmao.interceptors.CostTimeInterceptor"></interceptor>
<interceptor-stack name="mystack">
<interceptor-ref name="exception"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="i18n"/>
<interceptor-ref name="checkbox"/>
<interceptor-ref name="datetime"/>
<interceptor-ref name="multiselect"/>
<interceptor-ref name="params"/>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="chain"/>
<interceptor-ref name="modelDriven"/>
<interceptor-ref name="fileUpload"/>
<interceptor-ref name="staticParams"/>
<interceptor-ref name="actionMappingParams"/>
<interceptor-ref name="params"/>
<interceptor-ref name="conversionError"/>
<interceptor-ref name="validation">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
<interceptor-ref name="workflow">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
<!--定义自己的-->
<interceptor-ref name="costTimeInterceptor"></interceptor-ref>
<interceptor-ref name="demo1Interceptor"></interceptor-ref>
</interceptor-stack>
</interceptors>
</package>
<package name="p1" extends="my">
<!-- 声明自定义拦截器-->
<action name="demo1" class="com.sanmao.action.Demo1Action">
<!-- 使用自定义的拦截器:只要自己明确指定了一个拦截器,默认的都不起作用-->
<interceptor-ref name="mystack"></interceptor-ref>
<result>/success.jsp</result>
</action>
</package>
</struts>
Struts2 自定义拦截栈
最新推荐文章于 2019-08-21 22:09:14 发布