📅  最后修改于: 2021-01-11 06:26:46             🧑  作者: Mango
日期验证器检查给定日期是否在指定范围内。
为日期验证器定义了3个参数。
Parameter | Description |
---|---|
fieldName | specifies the field name that is to be validated. It is required in Plain-Validator only. |
min | specifies the minimum range. It is ignored bydefault. |
max | specifies the maximum range. It is ignored bydefault. |
dob
01/01/1980
01/01/2010
Date of Birth must be within ${min} and ${max}
01/01/1980
01/01/2010
Date of Birth must be within ${min} and ${max}
该jsp页面使用struts UI标记创建表单。它从用户那里接收名称,密码和电子邮件ID。
<%@ taglib uri="/struts-tags" prefix="s" %>
该操作类继承了ActionSupport类并覆盖了execute方法。
package com.javatpoint;
import java.util.Date;
import com.opensymphony.xwork2.ActionSupport;
public class Register extends ActionSupport{
private Date dob;
public Date getDob() {
return dob;
}
public void setDob(Date dob) {
this.dob = dob;
}
public String execute(){
return "success";
}
}
在这里,我们使用捆绑的验证器来执行验证。
01/01/1950
01/01/2010
Date of Birth must be between ${min} to ${max}
该xml文件通过名称输入和拦截器jsonValidatorWorkflowStack定义了额外的结果。
index.jsp
welcome.jsp
它是显示用户信息的简单jsp文件。
<%@ taglib uri="/struts-tags" prefix="s" %>
Date of Birth: