Www.helper3.com
热门关键字: php net javascript java
Struts2基础 专题
专题目录
您的位置:java > Struts2基础专题 > Struts2 基于XML校验
Struts2 基于XML校验
作者:--    发布时间:2019-11-20 10:12:22

以下是的各类字段级和非字段级验证在struts2列表:

date validator:

<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 validator:

<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 validator:

<field name="myemail">
<field-validator type="email">
   <message>
      must provide a valid email
   </message>
</field-validator>
</field>

expression validator:

非现场级验证,验证基于正则表达式提供。

<field-validator type="expression">
   <param name="expression">....</param>
   <message>
      failed to meet ognl expression  .... 
   </message>
</field-validator>

int validator:

<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 validator:

<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 validator:

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

requiredstring validator:

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

stringlength validator:

<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 validator:

<field-validator type="url">
   <param name="fieldname">myhomepageurl</param>
   <message>
         invalid homepage url
   </message>
</field-validator>

滚动到顶部 滚动到底部
网站声明:
本站部分内容来自网络,如您发现本站内容
侵害到您的利益,请联系本站管理员处理。
联系站长
QQ群:570078429
网站备案号:
粤ICP备17073857号