// 调用hibernate校验
ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
Validator validator = vf.getValidator();
Set<ConstraintViolation<BaseFormData>> set = validator.validate(baseFormData);
if (set.iterator().hasNext()){
throw new BusinessRuntimeException(set.iterator().next().getMessage());
}
网友评论