javax.validation.constraints.NotBlank 用法

javax.validation.UnexpectedTypeException:

HV000030:

No validator could be found for constraint 'javax.validation.constraints.NotBlank' validating type 'java.lang.Integer'. Check configuration for 'finalNum'
    at
org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.getExceptionForNullValidator(ConstraintTree.java:108)
    at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.getInitializedConstraintValidator(ConstraintTree.java:140)
    at org.hibernate.validator.internal.engine.constraintvalidation.SimpleConstraintTree.validateConstraints(SimpleConstraintTree.java:55)  

 

解答 1:@NotBlank  只能作用在String上,不能为null,而且调用trim()后,长度必须大于0,   故用在integer上报错,data上报错。

           

你可能感兴趣的:(java)