struts1.3中报错

struts1.3中<struts-config>报错
一个项目中struts-config.xml文件老是报错
在<struts-config>的标签中报错:
The content of element type "struts-config" must match "(display-name?,description?,form-beans?,global-exceptions?,global-forwards?,action-
 mappings?,controller?,message-resources*,plug-in*)".
显然,是我的文件中标签的不匹配造成的,但是我找了一圈,发现标签的使用都很正常。该xml文件如下:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
    <form-beans>
<form-bean name="employeeForm" type="com.hsp.web.forms.EmployeeForm" />
</form-beans>
   <action-mappings>
     <action path="/login"  parameter="flag" name="employeeForm">
          <forward name="ok" path="WEB-INF/MainFrame.jsp"></forward>
     </action>
          <!-- 配置employeeaction -->
<action path="/employee" name="employeeForm" parameter="flag">
<forward name="goAdd" path="/WEB-INF/addEmpUi.jsp" />
<forward name="goList" path="/WEB-INF/listEmp.jsp"/>
<forward name="goUp" path="/WEB-INF/updEmpUi.jsp"/>
</action>
   </action-mappings>
    <!-- 配置全局跳转 -->
<global-forwards>
<forward name="opererr" path="/WEB-INF/err.jsp" />
<forward name="operok" path="/WEB-INF/welcome.jsp" />
</global-forwards>
<controller>
  <set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor"/>
</controller>
</struts-config>
上面的action已经被spring代理了,所以没有配置type属性
我试着去掉一些标签,发现是<action-mappings>标签的问题(去掉该标签后没有报错了),我们知道,“?”是代表该标签只能出现零次或一次,“*”代表是零次或多次,在这个xml文件中也就出现了一次,但是也没理由报错,而且标签都是一一匹配的。在网上找了好久,才发现这是个比较隐蔽的错误,就是各个成员的顺序错误也会报错的。把<action-mappings>整体往下移动,移动到<global-forwards>的后面就没报错了。-_-
如下:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
    <form-beans>
<form-bean name="employeeForm" type="com.hsp.web.forms.EmployeeForm" />
</form-beans>
    <!-- 配置全局跳转 -->
<global-forwards>
<forward name="opererr" path="/WEB-INF/err.jsp" />
<forward name="operok" path="/WEB-INF/welcome.jsp" />
</global-forwards>
   <action-mappings>
     <action path="/login"  parameter="flag" name="employeeForm">
          <forward name="ok" path="WEB-INF/MainFrame.jsp"></forward>
     </action>
          <!-- 配置employeeaction -->
<action path="/employee" name="employeeForm" parameter="flag">
<forward name="goAdd" path="/WEB-INF/addEmpUi.jsp" />
<forward name="goList" path="/WEB-INF/listEmp.jsp"/>
<forward name="goUp" path="/WEB-INF/updEmpUi.jsp"/>
</action>
   </action-mappings>
<controller>
  <set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor"/>
</controller>
</struts-config>

你可能感兴趣的:(struts-config报错)