出现原因: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的大家有帮助哦! (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|