自定义拦截器没有加载

来源:互联网 发布:程序员怎么挣钱 编辑:程序博客网 时间:2024/06/05 18:20

写拦截器时,自己定义的拦截器总是不加载,
出现过的错误如下
- 元素类型为 “struts” 的内容必须匹配 “((package|include|bean|constant)*,unknown-handler-stack?)”。 at (null:13:10)
错误代码如下

<struts><interceptors>    <interceptor name="MyInterceptor" class="org.interceptor.MyInterceptor"></interceptor></interceptors><package name="default" extends="struts-default">    <action name="test123" class="org.action.TestAction">        <interceptor-ref name="defaultStack"></interceptor-ref>        <interceptor-ref name="MyInterceptor"></interceptor-ref>        <result name="success">/MyJsp.jsp</result>    </action></package></struts>    

因为我把

<interceptors>    <interceptor name="MyInterceptor" class="org.interceptor.MyInterceptor"></interceptor>

这段写在package外面的,所有出错了
更正,写在package里面就好了

<struts><package name="default" extends="struts-default"><interceptors>    <interceptor name="MyInterceptor" class="org.interceptor.MyInterceptor"></interceptor></interceptors>    <action name="test123" class="org.action.TestAction">        <interceptor-ref name="defaultStack"></interceptor-ref>        <interceptor-ref name="MyInterceptor"></interceptor-ref>        <result name="success">/MyJsp.jsp</result>    </action></package></struts>    

然后出现了

  • Could not find action or result No result defined for action org.action.TestAction and result success
    因为我的action的name写的是test,后来改成test123,可以了
    到目前为止我遇到的这种有login,test
0 0
原创粉丝点击