Questions tagged «hibernate-validator»

15
使用Hibernate Validator(JSR 303)进行跨字段验证
Hibernate Validator 4.x中是否有跨域验证的实现(或第三方实现)?如果没有,实现跨域验证器的最干净方法是什么? 例如,如何使用API​​来验证两个bean属性是否相等(例如,验证密码字段与密码验证字段匹配)。 在注解中,我期望类似: public class MyBean { @Size(min=6, max=50) private String pass; @Equals(property="pass") private String passVerify; }

10
javax.validation.ValidationException:HV000183:无法加载'javax.el.E​​xpressionFactory'
我尝试使用休眠验证器编写非常简单的应用程序: 我的步骤: 在pom.xml中添加以下依赖项: <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>5.1.1.Final</version> </dependency> 编写代码: class Configuration { Range(min=1,max=100) int threadNumber; //... public static void main(String[] args) { ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); Validator validator = factory.getValidator(); Configuration configuration = new Configuration(); configuration.threadNumber = 12; //... Set<ConstraintViolation<Configuration>> constraintViolations = validator.validate(configuration); System.out.println(constraintViolations); } } 我得到以下stacktrace: Exception in thread …

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.