另外,经查源码,发现方法public List
另外附上,使用xml校验的java源码例子:
import java.lang.reflect.Field; import java.util.List; import net.sf.oval.ConstraintViolation; import net.sf.oval.Validator; import net.sf.oval.configuration.xml.XMLConfigurer; public class TrainData { private String xm; private String sfzh; private String qjStart; private String qjEnd; private String rxrq; // @ValidateWithMethod(methodName = "isValid", parameterType = String.class) private String yhcs; private String kxlh; public TrainData(){} public TrainData(String xm, String sfzh, String qjStart, String qjEnd, String rxrq, String yhcs, String kxlh){ this.xm = xm; this.sfzh = sfzh; this.qjStart = qjStart; this.qjEnd = qjEnd; this.rxrq = rxrq; this.yhcs = yhcs; this.kxlh = kxlh; } private boolean isValid(String xm) { //to do 数据库根据身份证号查询出的姓名进行比较 if("1".equals(xm)) return true; return false; } public static void main(String[] args) { try{ TrainData data = new TrainData("刘艳梅","11010619770201304","","","20050101","2","123"); XMLConfigurer x2 = new XMLConfigurer(); x2.fromXML(XMLConfigurationTest.class.getResourceAsStream("TrainDataValidation.xml")); Validator validator = new Validator(x2); // Validator validator = new Validator(); // Field f=TrainData.class.getDeclaredField("xm"); // List所有参考的网址:
http://oval.sourceforge.net/userguide.html,
http://oval.sourceforge.net/api/index.html
http://sourceforge.net/projects/oval/forums/forum/488110/topic/4709092