前端之家收集整理的这篇文章主要介绍了
模版:XxxAction-validation.xml,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC
"-//OpenSymphony Group//XWork Validator 1.0//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
<-- 1.必填字符串校验器 -->
<validators>
<field name="name">
<field-validator type="requiredstring">
<!--去空格-->
<param name="trim">true</param>
<message>姓名是必需的!</message>
</field-validator>
</field>
</validators>
<-- 2.必填校验器 -->
<validators>
<field name="name">
<field-validator type="required">
<message>姓名是必需的!</message>
</field-validator>
</field>
</validators>
<-- 3.整数校验器 -->
<validators>
<field name="age">
<field-validator type="int">
<param name="min">18</param>
<param name="max">100</param>
<message>年龄必须在18至100之间</message>
</field-validator>
</field>
</validators>
<-- 4.日期校验器 -->
<validators>
<field name="date">
<field-validator type="date">
<param name="min">1980-01-01</param>
<param name="max">2009-12-31</param>
<message>日期必须在1980-01-01至2009-12-31之间</message>
</field-validator>
</field>
</validators>
<-- 5.邮件地址校验器 -->
<validators>
<field name="email">
<field-validator type="email">
<message>必须输入有效的电子邮件地址 </message>
</field-validator>
</field>
</validators>
<-- 6.网址校验器 -->
<validators>
<field name="url">
<field-validator type="url">
<message>必须输入有效的网址 </message>
</field-validator>
</field>
</validators>
<-- 7.字符串长度校验器 -->
<validators>
<field name="password">
<field-validator type="stringlength">
<param name="minLength">6</param>
<param name="maxLength">20</param>
<message>密码长度必须在6到20之间</message>
</field-validator>
</field>
</validators>
<-- 8.正则表达式校验器 -->
<validators>
<field name="xh">
<field-validator type="regex">
<param name="expression"><![CDATA[(\d{6})]]></param>
<message>学号必须是6位的数字</message>
</field-validator>
</field>
</validators>
原文链接:https://www.f2er.com/xml/297898.html