zoukankan      html  css  js  c++  java
  • Struts2 XML验证器

    以下是Struts2 中可用的各种字段级别和非字段级别类型的验证列表:

    date验证器

    <field name="birthday">
    <field-validator type="date">
       <param name="min">01/01/1990</param>
       <param name="max">01/01/2000</param>
       <message>
          Birthday must be within ${min} and ${max}
       </message>
    </field-validator>
    </field>
    

      

    double验证器

    <field name="percentage">
    <field-validator type="double">
       <param name="minExclusive">0.123</param>
       <param name="maxExclusive">99.98</param>
       <message>
          Percentage needs to be between ${minExclusive}
          ${maxExclusive} (exclusive)
       </message>
    </field-validator>
    </field>
    

      

    email验证器

    <field name="myEmail">
    <field-validator type="email">
       <message>
          Must provide a valid email
       </message>
    </field-validator>
    </field>
    

      

    expression验证器

    基于正则表达式提供验证的非字段级验证器。
    <field-validator type="expression">
       <param name="expression">....</param>
       <message>
          Failed to meet Ognl Expression  .... 
       </message>
    </field-validator>
    

      

    int验证器

    <field name="age">
    <field-validator type="int">
       <param name="min">5</param>
       <param name="max">50</param>
       <message>
          Age needs to be between ${min} and ${max}
       </message>
    </field-validator>
    </field>
    

      

    regex验证器

    <field name="myStrangePostcode">
    <field-validator type="regex">
       <param name="fieldName">myStrangePostcode</param>
       <param name="expression">
          <![CDATA[([aAbBcCdD][123][eEfFgG][456])]]>
       </param>
    </field-validator>
    </field>
    

      

    required验证器

    <field name="username">
    <field-validator type="required">
       <message>
           username must not be null
       </message>
    </field-validator>
    </field>
    

      

    requiredstring验证器

    <field name="username">
    <field-validator type="requiredstring">
     <param name="trim">true</param>
       <message>
           username must not be null
       </message>
    </field-validator>
    </field>
    

      

    stringlength验证器

    <field name="username">
    <field-validator type="stringlength">
     <param name="minLength">10</param>
     <param name="maxLength">10</param>
     <param name="trim">true</param>
       <message>
           Your username needs to be 10 characters long
       </message>
    </field-validator>
    </field>
    

      

    url验证器

    <field-validator type="url">
       <param name="fieldName">myHomePageURL</param>
       <message>
             Invalid homepage url
       </message>
    </field-validator>
    

      

  • 相关阅读:
    Buffer -nodejs
    Tip提示框另类写法
    SASS入门
    界面设计必须要权衡的三个要素
    如何快速出稿一个优秀APP的构图
    如何画好一套线性图标
    Ui培训之如何设计极简三色图标
    移动APP设计国外资源总汇
    移动界面UI颜色设计
    APP专业视觉设计基础标准要求
  • 原文地址:https://www.cnblogs.com/w894819398/p/7298164.html
Copyright © 2011-2022 走看看