<?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="aop" namespace="/aop" extends="struts-default">
<interceptors>
<interceptor name="myinter" class="app.aop.MyIntercepter"></interceptor>
<interceptor-stack name="myStack">
<interceptor-ref name="defaultStack"></interceptor-ref>
<interceptor-ref name="myinter"></interceptor-ref>
</interceptor-stack>
</interceptors>
<!-- 配置struts2框架运行时,默认执行自定义拦截器栈 -->
<default-interceptor-ref name="myStack"></default-interceptor-ref>
<action name="userAction_save" class="app.aop.UserAction" method="save">
<result name="success">/aop/success.jsp</result>
<result name="input">/aop/error.jsp</result>
</action>
</package>
</struts>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="aop" namespace="/aop" extends="struts-default">
<interceptors>
<interceptor name="myinter" class="app.aop.MyIntercepter"></interceptor>
<interceptor-stack name="myStack">
<interceptor-ref name="defaultStack"></interceptor-ref>
<interceptor-ref name="myinter"></interceptor-ref>
</interceptor-stack>
</interceptors>
<!-- 配置struts2框架运行时,默认执行自定义拦截器栈 -->
<default-interceptor-ref name="myStack"></default-interceptor-ref>
<action name="userAction_save" class="app.aop.UserAction" method="save">
<result name="success">/aop/success.jsp</result>
<result name="input">/aop/error.jsp</result>
</action>
</package>
</struts>
本文介绍如何在Struts2框架中配置自定义拦截器,并通过示例展示如何设置拦截器栈来覆盖默认行为。同时,文章还介绍了如何为特定Action指定自定义拦截器。
168

被折叠的 条评论
为什么被折叠?



