Caused by: 元素类型为 "package" 的内容必须匹配 "(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*
这样的顺序放置
以下是struts.xml中的package的内容:
......
<package name="default" namespace="/" extends="struts-default"> <default-action-ref name="index" />
<action name="index">
<result>index.jsp</result>
</action> <global-results> <result name="error">/WEB-INF/pages/public/error.jsp</result> </global-results> <global-exception-mappings> <exception-mapping exception="java.lang.Exception" result="error" /> </global-exception-mappings> </package>
.....
解决办法:将action放置到如下位置就好了
<package name="default" namespace="/" extends="struts-default"> <default-action-ref name="index" /> <global-results> <result name="error">/WEB-INF/pages/public/error.jsp</result> </global-results> <global-exception-mappings> <exception-mapping exception="java.lang.Exception" result="error" /> </global-exception-mappings> <action name="index"> <result>index.jsp</result> </action> </package>