zoukankan      html  css  js  c++  java
  • 【struts2】【2】添加interceptor出错

    原本全都正确的逻辑。添加interceptor后显示如下错误。

    Caused by: The content of element type "package" must match "(result-types?,interceptors?,default-interceptor-ref?,default-action-ref?,default-class-ref?,global-results?,global-exception-mappings?,action*)". 

    原因是struts的dtd定义中对package定义为:package (result-types?,interceptors?,default-interceptor-ref?,default-action-ref?,default-class-ref?,global-results?,global-exception-mappings?,action*)

    这里表示package种的元素出现是有先后顺序的,要么不添加,要么就按照顺序。

    把interceptor位置换一下。

     1     <package name="front" namespace="/front" extends="struts-default">
     2         <result-types>
     3             <result-type name="tiles"
     4                 class="org.apache.struts2.views.tiles.TilesResult" />
     5         </result-types>
     6 
     7         <interceptors>
     8             <interceptor name="login" class="loginInterceptor" /> 
     9             <interceptor name="adminInfoInterceptor" class="adminInfoInterceptor" />
    10             <interceptor-stack name="loginStack">
    11                 <interceptor-ref name="login" />                 
    12                 <interceptor-ref name="adminInfoInterceptor"/>     
    13                 <interceptor-ref name="defaultStack" />
    14             </interceptor-stack>
    15         </interceptors>
    16         
    17         <global-results>
    18             <result name="pageNotFind">/front/pageNotFind.jsp</result>
    19             <result name="webNotFind">/front/pageNotFind.jsp</result>
    20         </global-results>
    21     
    22         <!-- 网站首页 -->
    23         <action name="goWebIndex" class="goWebIndexAction">
    24             <result name="success" type="tiles">${web.pageTemplate.dir}/index.tiles</result>
    25         </action>
    26 
    27     </package>
  • 相关阅读:
    HTML5 新标签
    lAMBDA表达式剖析
    whitespace 属性设置如何处理元素内的空白。
    "~/" asp.net 表示路径的方法
    ASP.NET Session详解
    关于CSS Selector的优先级
    关于汉字转拼音
    ChildActionOnly + ActionName的用法
    html中的caption是什么用
    window.location.href location.href parent.location.href
  • 原文地址:https://www.cnblogs.com/qiudeqing/p/3114980.html
Copyright © 2011-2022 走看看