struts2 检验double不起作用
struts2检验double不起作用,对其它的作字符串检验又起作用检验的配置文件:<?xmlversion="1.0"encoding="UTF-8"?><!DOCTY...
struts2 检验double不起作用,对其它的作字符串检验又起作用
检验的配置文件:
<?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">
<validators>
<field name="siteName">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message>楼盘名称不能为空!</message>
</field-validator>
</field>
<field name="sellDate">
<field-validator type="date">
<message>日期格式不正确!</message>
</field-validator>
</field>
<field name="area">
<field-validator type="int">
<message>请输入正确的数值!</message>
</field-validator>
</field>
<field name="totalConstructionArea">
<field-validator type="double">
<message>请输入正确的数值!</message>
</field-validator>
</field>
<field name="cubageRate">
<field-validator type="double">
<message>请输入正确的数值!</message>
</field-validator>
</field>
<field name="virescenceRate">
<field-validator type="double">
<message>请输入正确的数值!</message>
</field-validator>
</field>
</validators>
interceptor的执行顺序是
1. 型别转换 (type conversion)
2. 获取参数信心(params )
3. 为验证等作准备(prepare)
4. 参数验证 (validation)
是类型转换不成功,所以系统先提示invalid field value for field
如果类型转换成功了,才再进行类型转换 展开
检验的配置文件:
<?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">
<validators>
<field name="siteName">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message>楼盘名称不能为空!</message>
</field-validator>
</field>
<field name="sellDate">
<field-validator type="date">
<message>日期格式不正确!</message>
</field-validator>
</field>
<field name="area">
<field-validator type="int">
<message>请输入正确的数值!</message>
</field-validator>
</field>
<field name="totalConstructionArea">
<field-validator type="double">
<message>请输入正确的数值!</message>
</field-validator>
</field>
<field name="cubageRate">
<field-validator type="double">
<message>请输入正确的数值!</message>
</field-validator>
</field>
<field name="virescenceRate">
<field-validator type="double">
<message>请输入正确的数值!</message>
</field-validator>
</field>
</validators>
interceptor的执行顺序是
1. 型别转换 (type conversion)
2. 获取参数信心(params )
3. 为验证等作准备(prepare)
4. 参数验证 (validation)
是类型转换不成功,所以系统先提示invalid field value for field
如果类型转换成功了,才再进行类型转换 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询