当前位置: 代码迷 >> J2EE >> 今日用刚学的拦截器 就算写了excludeMethods也还是都拦截了
  详细解决方案

今日用刚学的拦截器 就算写了excludeMethods也还是都拦截了

热度:52   发布时间:2016-04-17 23:46:32.0
今天用刚学的拦截器 就算写了excludeMethods也还是都拦截了
struts.xml


<struts>
<package name="zk" extends="struts-default">
<interceptors>
<interceptor name="bookInterceptor" class="zk.interceptors.BookInterceptor"> //自己创建的拦截器
</interceptor>

<interceptor-stack name="default">      //拦截器栈
<interceptor-ref name="bookInterceptor">
<param name="excludeMethods">addBook</param>   //应该是对addBook方法不拦截
</interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>   //默认拦截器栈
</interceptor-stack>
</interceptors>



<action name="bookAction-*" class="zk.actions.BookAction" method="{1}">
<result name="main">/main/main.jsp</result>
<result name="index">/main/index.jsp</result>
<result name="none">/main/none.jsp</result>
<result name="delete">/main/delete.jsp</result>
<result name="chenge">/main/chenge.jsp</result>

<interceptor-ref name="default"></interceptor-ref>                //这里用的拦截器

</action>



<action name="userAction-*" class="zk.actions.UserAction" method="{1}">
<result name="welcome">/main/welcome.jsp</result>
<result name="fail">/main/fail.jsp</result>
</action>


</package>
</struts>


为什么bookAction里的所有方法都拦截了,包括addBook
------解决方案--------------------
楼主看看这个!

http://blog.csdn.net/coolcoffee168/article/details/7963251
  相关解决方案