您的位置:首页 > 编程语言 > Java开发

Struts2 自定义拦截栈

2016-09-08 19:35 302 查看
<?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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  struts struts2.0