struts-config :
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts-config (View Source for full doctype...)>
- <form-bean name="loginActionForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="username" type="java.lang.String" />
<form-property name="password" type="java.lang.String" />
</form-bean>
</form-beans>
- <action input="/login.jsp" name="loginActionForm" path="/loginAction" scope="request" type="login.loginAction" validate="false">
<forward name="Success" path="/main.jsp" />
<forward name="Fail" path="/register.jsp" />
</action>
</action-mappings>
</struts-config>
web.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE web-app (View Source for full doctype...)>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
</web-app>
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE form-validation (View Source for full doctype...)>
- <form name="loginActionForm">
- <field property="username" depends="required,minlength">
<arg0 key="label.username" />
<arg1 name="minlength" key="${var:minlength}" resource="false" position="1" />
<var-name>minlength</var-name>
</var>
</field>
- <field property="password" depends="required,minlength">
<arg0 key="label.password" />
<arg1 name="minlength" key="${var:minlength}" resource="false" position="1" />
<var-name>minlength</var-name>
</var>
</field>
</form>
</formset>
</form-validation>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE form-validation (View Source for full doctype...)>
- <!--
$Header: /home/cvs/jakarta-struts/conf/share/validator-rules.xml,v 1.52 2004/07/25 12:00:20 niallp Exp $
$Revision: 1.52 $
$Date: 2004/07/25 12:00:20 $
This file contains the default Struts Validator pluggable validator
definitions. It should be placed somewhere under /WEB-INF and
referenced in the struts-config.xml under the plug-in element
for the ValidatorPlugIn.
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,
/WEB-INF/validation.xml"/>
</plug-in>
These are the default error messages associated with
each validator defined in this file. They should be
added to your projects ApplicationResources.properties
file or you can associate new ones by modifying the
pluggable validators msg attributes in this file.
# Struts Validator Error Messages
errors.required={0} is required.
errors.minlength={0} can not be less than {1} characters.
errors.maxlength={0} can not be greater than {1} characters.
errors.invalid={0} is invalid.
errors.byte={0} must be a byte.
errors.short={0} must be a short.
errors.integer={0} must be an integer.
errors.long={0} must be a long.
errors.float={0} must be a float.
errors.double={0} must be a double.
errors.date={0} is not a date.
errors.range={0} is not in the range {1} through {2}.
errors.creditcard={0} is an invalid credit card number.
errors.email={0} is an invalid e-mail address.
Note: Starting in Struts 1.2.0 the default javascript definitions have
been consolidated to commons-validator. The default can be overridden
by supplying a <javascript> element with a CDATA section, just as
in struts 1.1.
-->
<script></script>
<validator name="required" classname="org.apache.struts.validator.FieldChecks" method="validateRequired" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" msg="errors.required" />
<validator name="requiredif" classname="org.apache.struts.validator.FieldChecks" method="validateRequiredIf" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, org.apache.commons.validator.Validator, javax.servlet.http.HttpServletRequest" msg="errors.required" />
<validator name="validwhen" msg="errors.validwhen" classname="org.apache.struts.validator.validwhen.ValidWhen" method="validateValidWhen" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, org.apache.commons.validator.Validator, javax.servlet.http.HttpServletRequest" />
<validator name="minlength" classname="org.apache.struts.validator.FieldChecks" method="validateMinLength" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends="" msg="errors.minlength" jsFunction="org.apache.commons.validator.javascript.validateMinLength" />
<validator name="maxlength" classname="org.apache.struts.validator.FieldChecks" method="validateMaxLength" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends="" msg="errors.maxlength" jsFunction="org.apache.commons.validator.javascript.validateMaxLength" />
<validator name="mask" classname="org.apache.struts.validator.FieldChecks" method="validateMask" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends="" msg="errors.invalid" />
<validator name="byte" classname="org.apache.struts.validator.FieldChecks" method="validateByte" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" depends="" msg="errors.byte" jsFunctionName="ByteValidations" />
分享到:
相关推荐
用jsp、action、struts-config.xml配置文件,举例说明了DynaActionForm 在struts1 中的作用。
DynaActionForm(动态表单)介绍及应用,Struts framework中,ActionForm对象的封装及应用,通过Struts framework中的DynaActionForm类及其子类可以实现动态的ActionForm ,动态的ActionForm允许你通过Struts的配置...
- JSP页面负责显示数据和接收用户输入,通过Struts标签库(如struts-tiles或struts-bean标签)与ActionForm或DynaActionForm交互。 通过以上步骤,你可以使用Eclipse构建一个基本的Struts1.2应用程序。不过,实际...
它继承自 `org.apache.struts.action.DynaActionForm` 类,并且可以通过 `<form-property>` 标签在 `struts-config.xml` 文件中定义表单字段。 ```xml <form-bean name="xxForm" type="org.apache.struts.action....
Struts是Java Web开发中的一个经典框架,它在MVC(Model-View-Controller)设计模式的基础上提供了一种实现方式,极大地简化了Web应用的构建。ActionForm是Struts框架中一个关键组件,用于处理用户从视图层提交的...
这里,我们使用了`DynaActionForm`,它是Struts 1.0中动态表单的实现,可以方便地处理不同类型的表单字段。 3. **创建表单Bean**:在Struts应用中,表单Bean(通常是DynaActionForm)用于封装用户输入的数据。对于...
DynaActionForm是基于org.apache.struts.action.DynaActionForm的,它不需要预先定义属性,而是允许在运行时动态地添加、修改和删除属性。在配置文件中,我们使用`<form-bean>`元素来声明一个DynaActionForm,并通过...
05 Struts_05DynaActionForm : 相对应ActionForm来说,动态ActionForm只需要在配置文件中配置就可以了,但是它不能实现验证功能,演示人机交互实例。 06 Struts_06Filter : 中文编码的统一处理,通过Struct的请求...
<controller processorClass="org.apache.struts.action.DynaActionForm"> <!-- Controller配置 --> <!-- 全局转发配置 --> <!-- 国际化资源配置 --> </struts-config> ``` - **web.xml**:作为...
在"Struts原理(二)"中,我们将深入探讨如何利用Struts框架的一些高级特性,如DispatchAction、资源文件的国际化、错误信息的显示、DynaActionForm以及实体对象作为Form属性的使用。 **掌握DispatchAction** ...
在struts.xml中定义一个DynaActionForm,然后在Action中通过DynaActionForm获取属性。 9. **文件上传**:Struts2支持文件上传功能。在JSP中使用`enctype="multipart/form-data"`来指定文件上传的表单类型。在...
- **DynaActionForm** 和 **DynaValidatorForm** 是Struts提供的两种特殊的ActionForm。DynaActionForm允许你在运行时动态地构建表单的属性,而DynaValidatorForm提供了在表单数据验证时的动态构建功能。 - **...
3. ** DynaActionForm**: 这是Struts中的动态表单类,相比于传统的ActionForm,DynaActionForm不需要预先定义字段。它的字段可以在运行时动态添加,这使得表单的结构可以根据服务器端的业务逻辑改变。 4. **Struts-...
- **struts-bean.jar**:提供数据绑定和标签库支持,包括BeanUtils和DynaActionForm。 - **struts-html.jar**:包含HTML表单相关的标签库,如表单元素、链接、图像等。 - **struts-logic.jar**:提供逻辑控制标签,...
2. **struts-bean.jar**:这个JAR文件包含了一些用于数据绑定和展示的类,如ValueStack、BeanUtils和 DynaActionForm。它们帮助将用户输入的数据映射到Java对象,并反之。 3. **struts-html.jar**:提供了各种HTML...
<form-bean name="messageForm" type="org.apache.struts.action.DynaActionForm"> ``` 定义了一个动态表单Bean,用于接收用户的输入数据。 #### 三、Spring配置文件详解 Spring框架的核心配置文件(如...
<form-bean name="actionForm" type="org.apache.struts.action.DynaActionForm"> <form-property name = "filedata" type = "org.apache.struts.upload.FormFile" /> name="actionForm" ...
4. `struts-bean.jar`:包含了一些常用的Bean类,如 DynaActionForm,用于动态定义表单字段。 5. `struts-config.xml`:这是Struts配置文件,定义了Action和ActionMapping,以及与其他服务的连接。 通过阅读和理解...