下面是dtd文件:
<?xml version="1.0" encoding="UTF-8"?>
<!ENTITY % Boolean "(true|false|yes|no)">
<!ENTITY % Integer "CDATA">
<!ELEMENT struts-config (menu-path,description?, form-beans?,action-mappings?) >
<!ELEMENT menu-path (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT form-beans (form-bean*)>
<!ELEMENT form-bean (description,form-property*)>
<!ATTLIST form-bean name CDATA #REQUIRED>
<!ELEMENT form-property EMPTY>
<!ATTLIST form-property prefix CDATA #REQUIRED>
<!ATTLIST form-property name CDATA #REQUIRED>
<!ATTLIST form-property type CDATA #IMPLIED>
<!ATTLIST form-property size %Integer; #IMPLIED>
<!ATTLIST form-property notnull %Boolean; #IMPLIED>
<!ATTLIST form-property initval CDATA #IMPLIED>
<!ATTLIST form-property description CDATA #IMPLIED>
<!ELEMENT action-mappings (action*)>
<!ELEMENT action (description?,forward*)>
<!ATTLIST action name CDATA #REQUIRED>
<!ATTLIST action className CDATA #REQUIRED>
<!ATTLIST action methodName CDATA #REQUIRED>
<!ATTLIST action path CDATA #REQUIRED>
<!ATTLIST action input CDATA #IMPLIED>
<!ELEMENT forward EMPTY>
<!ATTLIST forward name CDATA #REQUIRED>
<!ATTLIST forward path CDATA #REQUIRED>
下面是对应的一个XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config SYSTEM "greatwall-struts.dtd">
<struts-config>
<menu-path>/app/user/</menu-path>
<description>用户处理Struts配置文件</description>
<form-beans>
<form-bean name="userFormBean" >
<description>用户登录表单处理</description>
<form-property prefix="record" name="username" description="用户名" notnull="true" size="16" type="string" initval="admin"/>
<form-property prefix="record" name="password" description="密码" />
</form-bean>
</form-beans>
<action-mappings>
<action methodName="listUser" className="com.greatwall.user.action.UserAction" name="userFormBean" path="/ListUser.do" >
<description>用户列表</description>
<forward name="success" path="listUser.jsp" />
<forward name="failure" path="listUser.jsp" />
</action>
<action methodName="deleteUser" className="com.greatwall.user.action.UserAction" name="userFormBean" path="/deleteUser.do" >
<description>删除用户</description>
<forward name="success" path="listUser.jsp" />
<forward name="failure" path="listUser.jsp" />
</action>
</action-mappings>
</struts-config>
不能松懈,困难很多,但是坚持就是胜利!