转载自:http://blog.csdn.net/y591174893/article/details/7604143
“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*)". ”
就是
result-types
interceptors
default-interceptor-ref
default-action-ref
default-class-ref
global-results
global-exception-mappings
action*(就是所有的action放到最后)
struts2 默认action
<default-action-ref name="error" />
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error" />
</global-exception-mappings>
<action name="error">
<result>/common/error.jsp</result>
</action>
当上面没有
<default-action-ref name="error" />
的时候,URL是 http://localhost:8080/Struts2_1400_DefaultAction/,将会出错,说There is no Action mapped for namespace / and action name.-[unknow location]。因为你没写action,当然找不着
如果
<default-action-ref name="error" />
存在,则如果有人访问这个namespace="/"的时候,如果当在namespace="/"下找不到相对应的action,则会走default action,即是index.action。比如http://localhost:8080/Struts2_1400_DefaultAction/aasfadsfdsgewtytyyukuipo, 则会走默认的index.action
在浏览器地址栏中请求的.JSP文件不存在或错误时,可以再web.xml中配置,如:
<error-page>
</error-page>