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

前端之家收集整理的这篇文章主要介绍了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的大家有帮助哦!

原文链接:https://www.f2er.com/xml/300235.html

猜你在找的XML相关文章