<validators> <field name="username"> <field-validator type="requiredstring"> <param name="trim">true</param> <message>用户名不能为空</message> </field-validator> <field-validator type="regex"> <param name="regexExpression"><![CDATA[(\w{4,20})]]></param> <message>长度为4-25</message> </field-validator> </field> <field name="password"> <field-validator type="requiredstring"> <param name="trim">true</param> <message>密码不能为空</message> </field-validator> <field-validator type="regex"> <param name="regexExpression"><![CDATA[(\w{4,20})]]></param> <message>密码4-25</message> </field-validator> </field> </validators>
修改:
<param name="expression"><![CDATA[(\w{4,25})]]></param> 参数名字改为regexExpression了 <param name="regexExpression"><![CDATA[(\w{4,25})]]></param>