在写Struts的配置文件的时候,遇到了这样的问题。查了半天也没有发现哪里出现错误了。。。这是我的配置文件的代码:
<struts>
<include file="struts-default.xml"></include>
<constant name="struts.il8n.encoding" value="utf-8"></constant>
<<u><span style="color:#FF0000;">package </span></u>name="Mystruts" extends="struts-default" namespace="/test">
<action name="test" class="actions.TestAction">
<result name="seccess">/test.jsp</result>
</action>
<interceptors>
<!-- 定义拦截器 -->
<interceptor name="interceptor1" class="inters.Interceptor1"></interceptor>
<interceptor name="interceptor2" class="inters.Interceptor2"></interceptor>
<!-- 定义拦截器栈 -->
<interceptor-stack name="mystack">
<interceptor-ref name="Interceptor1"></interceptor-ref>
<interceptor-ref name="Interceptor2"></interceptor-ref>
</interceptor-stack>
</interceptors>
</package>
</struts>
然后在如上的package处,会提示错误,错误的具体信息如下所示:
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*)".
然后在网上查了半天,发现这个错误的意思是,package里元素必须按照一定的顺序排列。这个顺序
就是
result-types
interceptors
default-interceptor-ref
default-action-ref
default-class-ref
global-results
global-exception-mappings
action
意思也就是所有的action放到最后。
果然将action的内容放在package的最后面,就没有错误啦。