出现原因: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 举报,一经查实,本站将立刻删除。