org.xml.sax.SAXParseException The content of element type "package" must match "(result-types?,inter

出现原因: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*)". at (null:59:11)

错误代码:

<package name="helloworld" extends="struts-default" namespace="/ss">



<global-results>
<result name="math-exception">/error.jsp</result>
</global-results>

<interceptors>
<interceptor-stack name="myStack">
<interceptor-ref name="timer"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>

<default-interceptor-ref name="myStack"></default-interceptor-ref>
<global-exception-mappings>
<exception-mapping result="math-exception" exception="java.lang.AritheticException"></exception-mapping>
<exception-mapping result="math-exception" exception="java.lang.Exception"></exception-mapping>
</global-exception-mappings>






<action name="helloworldAction" class="action.HelloWorldAction" >

。。。

</package>

错误原因是:package" must match "(result-types?,interceptors?,default-interceptor-ref?,default-action-ref?,default-class-ref?,global-results?,global-exception-mappings?,action*)意思是package包下面的元素的次序分别为result-types?,interceptors?,default-interceptor-ref?,default-action-ref?,default-class-ref?,global-results?,global-exception-mappings?,action*次序不能乱哦,?号表示可以出现一次或者不出现,*号表示可以出现一次或者多次,并且严格按照上面的出场次序来,否则就报错。

改过后的代码为:

<package name="helloworld" extends="struts-default" namespace="/ss">
<interceptors>
<interceptor-stack name="myStack">
<interceptor-ref name="timer"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="myStack"></default-interceptor-ref>

<global-results>
<result name="math-exception">/error.jsp</result>
</global-results>

<global-exception-mappings>
<exception-mapping result="math-exception" exception="java.lang.AritheticException"></exception-mapping>
<exception-mapping result="math-exception" exception="java.lang.Exception"></exception-mapping>
</global-exception-mappings>


这样控制台就不会报错了,希望对学习struts2的大家有帮助哦!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值