/action>
/action-mappings>
ActionMapping就是用来描述一个Action的URL、具体实现的文件、相对应的ActionForm 数据属性(request or session)、是否需要进行数据校验和回写、以及处理完成后可能跳转的URL.
而ActionForward你就可以理解为Action 操作完成后的跳转URL,Action在处理完相关操作后,返回的是一个ActionForward也就是告诉Struts我做完这个操作下一步到哪儿去。
构建Struts1.1运行环境
我的配置是居于Tomcat4.0以上版本讨论,其他的AppServer大致相同。
1:得到Struts1.1
http://jakarta.apache.org/builds/jakarta-struts/release/v1.1-b1/jakarta-struts-1.1-b1.zip
2:设置
把Struts.jar Copy到$Tomcat_home/common/lib 或你使用Struts的Appaction下的WEB-INF/lib下
在你使用Struts的Appaction下web.xml中增加下列配置
servlet>
servlet-name>action/servlet-name>
servlet-class>org.apache.struts.action.ActionServlet/servlet-class>
init-param>
param-name>config/param-name>
param-value>/WEB-INF/struts-config.xml/param-value>
/init-param>
init-param>
param-name>debug/param-name>
param-value>3/param-value>
/init-param>
init-param>
param-name>detail/param-name>
param-value>3/param-value>
/init-param>
load-on-startup>2/load-on-startup>
/servlet>
taglib>
taglib-uri>/WEB-INF/struts-html.tld/taglib-uri>
taglib-location>/WEB-INF/struts-html.tld/taglib-location>
/taglib>
taglib>
taglib-uri>/WEB-INF/struts-logic.tld/taglib-uri>
taglib-location>/WEB-INF/struts-logic.tld/taglib-location>
/taglib>
!-- Nested Tag Library Descriptor --
taglib>
taglib-uri>/WEB-INF/struts-nested.tld/taglib-uri>
taglib-location>/WEB-INF/struts-nested.tld/taglib-location>
/taglib>
!-- Template Tag Library Descriptor --
taglib>
taglib-uri>/WEB-INF/struts-template.tld/taglib-uri>
taglib-location>/WEB-INF/struts-template.tld/taglib-location>
/taglib>
Struts1.1中提供了很具体的例子,你可以仔细看看.
接下来你该根据需要配置struts-config.xml,以下是一个简单的例子
?xml version="1.0" encoding="ISO-8859-1" ?>
!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
struts-config>
!-- ========== Form Bean Definitions =================================== --
form-beans>
!-- Registration form bean --
form-bean name="useregForm"
type="com.bingo.finance.action.UserForm"/>
/form-beans>
!-- ========== Global Forward Definitions ============================== --
global-forwards>
forward name="error" path="/error.jsp"/>
/global-forwards>
!-- ========== Action Mapping Definitions ============================== --
action-mappings>
!-- Registration Action --
action path="/usereg"
type="com.bingo.finance.action.UseregAction"
name="useregForm"
scope="request"
validate="true"
input="/usereg.jsp">
forward name="success" path="/msg.jsp"/>
/action>
/action-mappings>
!-- ========== Message Resources Definitions =========================== --
message-resources
parameter="com.bingo.finance.common.DisplayMsg"/>
!-- ========== Plug Ins Configuration ================================== --
!-- Add multiple validator resource files by setting the pathname property --
plug-in className="org.apache.struts.validator.ValidatorPlugIn">
set-property property="pathname" value="/WEB-INF/validator-rules.xml"/>
set-property property="pathname" value="/WEB-INF/validation.xml"/>
/plug-in>
/struts-config>
上面的英文我相信你能够看懂。我就不做解释了。你需要继续配置validation.xml了,看如下
简单的例子.
form-validation>
formset>
form name="useregForm">
field property="username"
depends="required,mask,minlength,maxlength">
arg0 key="common_username"/>