📅  最后修改于: 2021-01-11 06:28:45             🧑  作者: Mango
双重验证器检查给定的浮点数是否在指定范围内。可用于产品价格等
为双重验证器定义了5个参数。
Parameter | Description |
---|---|
fieldName | specifies the field name that is to be validated. It is required in Plain-Validator only. |
minInclusive | specifies the minimum inclusive value. It is ignored bydefault. |
maxInclusive | specifies the maximum inclusive value. It is ignored bydefault. |
minExclusive | specifies the minimum exclusive value. It is ignored bydefault. |
maxExclusive | specifies the maximum exclusive value. It is ignored bydefault. |
price
100.0
10000.0
Price must be between ${minInclusive} and ${maxInclusive}
100.0
10000.0
Price must be between ${minInclusive} and ${maxInclusive}
该jsp页面使用struts UI标记创建表单。它从用户那里接收名称,密码和电子邮件ID。
<%@ taglib uri="/struts-tags" prefix="s" %>
该操作类继承了ActionSupport类并覆盖了execute方法。
package com.javatpoint;
import com.opensymphony.xwork2.ActionSupport;
public class Register extends ActionSupport{
private int id;
private double price;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String execute(){
return "success";
}
}
在这里,我们使用捆绑的验证器来执行验证。
100.0
9999.9
Price must be between ${minInclusive} to ${maxExclusive}
该xml文件通过名称输入和拦截器jsonValidatorWorkflowStack定义了额外的结果。
index.jsp
welcome.jsp
它是显示用户信息的简单jsp文件。
<%@ taglib uri="/struts-tags" prefix="s" %>
Product Id:
Product price: