`

struts DynaActionForm

    博客分类:
  • Java
阅读更多
struts-config :
 <?xml version="1.0" encoding="UTF-8" ?>
  <!DOCTYPE struts-config (View Source for full doctype...)>
- <struts-config>
- <form-beans>
- <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-mappings>
- <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...)>
- <web-app>
- <servlet>
  <servlet-name>action</servlet-name>
  <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
- <init-param>
  <param-name>application</param-name>
  <param-value>ApplicationResources</param-value>
  </init-param>
- <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>2</param-value>
  </init-param>
  <load-on-startup>2</load-on-startup>
  </servlet>
- <servlet-mapping>
  <servlet-name>action</servlet-name>
  <url-pattern>*.do</url-pattern>
  </servlet-mapping>
- <taglib>
  <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
  <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
  </taglib>
- <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>
- <taglib>
  <taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
  <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
  </taglib>
- <taglib>
  <taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
  <taglib-location>/WEB-INF/struts-template.tld</taglib-location>
  </taglib>
- <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-validation>
- <formset>
- <form name="loginActionForm">
- <field property="username" depends="required,minlength">
  <arg0 key="label.username" />
  <arg1 name="minlength" key="${var:minlength}" resource="false" position="1" />
- <var>
  <var-name>minlength</var-name>
  <var-value>3</var-value>
  </var>
  </field>
- <field property="password" depends="required,minlength">
  <arg0 key="label.password" />
  <arg1 name="minlength" key="${var:minlength}" resource="false" position="1" />
- <var>
  <var-name>minlength</var-name>
  <var-value>3</var-value>
  </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>
- <form-validation>
- <global>
  <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" />
 
分享到:
评论

相关推荐

    struts1配置文件中DynaActionForm的使用

    用jsp、action、struts-config.xml配置文件,举例说明了DynaActionForm 在struts1 中的作用。

    Struts framework中DynaActionForm(动态表单)介绍及应用

    DynaActionForm(动态表单)介绍及应用,Struts framework中,ActionForm对象的封装及应用,通过Struts framework中的DynaActionForm类及其子类可以实现动态的ActionForm ,动态的ActionForm允许你通过Struts的配置...

    Eclipse开发Struts1.2

    - JSP页面负责显示数据和接收用户输入,通过Struts标签库(如struts-tiles或struts-bean标签)与ActionForm或DynaActionForm交互。 通过以上步骤,你可以使用Eclipse构建一个基本的Struts1.2应用程序。不过,实际...

    struts的总结(struts1.x)

    它继承自 `org.apache.struts.action.DynaActionForm` 类,并且可以通过 `&lt;form-property&gt;` 标签在 `struts-config.xml` 文件中定义表单字段。 ```xml &lt;form-bean name="xxForm" type="org.apache.struts.action....

    [摘]Struts 学习笔记之ActionForm

    Struts是Java Web开发中的一个经典框架,它在MVC(Model-View-Controller)设计模式的基础上提供了一种实现方式,极大地简化了Web应用的构建。ActionForm是Struts框架中一个关键组件,用于处理用户从视图层提交的...

    struts1.0的上传代码

    这里,我们使用了`DynaActionForm`,它是Struts 1.0中动态表单的实现,可以方便地处理不同类型的表单字段。 3. **创建表单Bean**:在Struts应用中,表单Bean(通常是DynaActionForm)用于封装用户输入的数据。对于...

    struts1_详解

    - **动态ActionForm**:`org.apache.struts.action.DynaActionForm`,支持动态属性的增删改查。 #### 五、Struts1 连接池与多模块操作 **5.1 数据库连接池** Struts1可以集成C3P0等连接池,但文档中提到的问题...

    struts7验证框架 struts7验证框架

    DynaActionForm是基于org.apache.struts.action.DynaActionForm的,它不需要预先定义属性,而是允许在运行时动态地添加、修改和删除属性。在配置文件中,我们使用`&lt;form-bean&gt;`元素来声明一个DynaActionForm,并通过...

    Struts1.3 备忘笔记

    05 Struts_05DynaActionForm : 相对应ActionForm来说,动态ActionForm只需要在配置文件中配置就可以了,但是它不能实现验证功能,演示人机交互实例。 06 Struts_06Filter : 中文编码的统一处理,通过Struct的请求...

    Struts1基本配置

    &lt;controller processorClass="org.apache.struts.action.DynaActionForm"&gt; &lt;!-- Controller配置 --&gt; &lt;!-- 全局转发配置 --&gt; &lt;!-- 国际化资源配置 --&gt; &lt;/struts-config&gt; ``` - **web.xml**:作为...

    Struts原理(二)

    在"Struts原理(二)"中,我们将深入探讨如何利用Struts框架的一些高级特性,如DispatchAction、资源文件的国际化、错误信息的显示、DynaActionForm以及实体对象作为Form属性的使用。 **掌握DispatchAction** ...

    struts2.1配置

    在struts.xml中定义一个DynaActionForm,然后在Action中通过DynaActionForm获取属性。 9. **文件上传**:Struts2支持文件上传功能。在JSP中使用`enctype="multipart/form-data"`来指定文件上传的表单类型。在...

    Struts+Spring+Hibernate开发实例.pdf

    - **DynaActionForm** 和 **DynaValidatorForm** 是Struts提供的两种特殊的ActionForm。DynaActionForm允许你在运行时动态地构建表单的属性,而DynaValidatorForm提供了在表单数据验证时的动态构建功能。 - **...

    struts动态表单实例

    3. ** DynaActionForm**: 这是Struts中的动态表单类,相比于传统的ActionForm,DynaActionForm不需要预先定义字段。它的字段可以在运行时动态添加,这使得表单的结构可以根据服务器端的业务逻辑改变。 4. **Struts-...

    struts-1.3.10

    - **struts-bean.jar**:提供数据绑定和标签库支持,包括BeanUtils和DynaActionForm。 - **struts-html.jar**:包含HTML表单相关的标签库,如表单元素、链接、图像等。 - **struts-logic.jar**:提供逻辑控制标签,...

    struts1 用到的所有jar包.rar

    2. **struts-bean.jar**:这个JAR文件包含了一些用于数据绑定和展示的类,如ValueStack、BeanUtils和 DynaActionForm。它们帮助将用户输入的数据映射到Java对象,并反之。 3. **struts-html.jar**:提供了各种HTML...

    struts1+spring+hibernate整合示例

    &lt;form-bean name="messageForm" type="org.apache.struts.action.DynaActionForm"&gt; ``` 定义了一个动态表单Bean,用于接收用户的输入数据。 #### 三、Spring配置文件详解 Spring框架的核心配置文件(如...

    struts1.x上传实例

    &lt;form-bean name="actionForm" type="org.apache.struts.action.DynaActionForm"&gt; &lt;form-property name = "filedata" type = "org.apache.struts.upload.FormFile" /&gt; name="actionForm" ...

    struts api & document

    4. `struts-bean.jar`:包含了一些常用的Bean类,如 DynaActionForm,用于动态定义表单字段。 5. `struts-config.xml`:这是Struts配置文件,定义了Action和ActionMapping,以及与其他服务的连接。 通过阅读和理解...

Global site tag (gtag.js) - Google Analytics