微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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?,action*)意思是package包下面的元素的次序分别为result-types?,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的大家有帮助哦!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念
xml文件介绍及使用
xml编程(一)-xml语法
XML文件结构和基本语法
第2章 包装类