[JAVA]Validator 运用

[JAVA]Validator 应用Java validator的应用JavaxAssertFalseAssertTrueDecimalMaxDecimalMinDigitsFutureM

[JAVA]Validator 应用

Java validator的应用

Javax
AssertFalse
AssertTrue
DecimalMax
DecimalMin
Digits
Future
Max
Min
NotNull
Null
Past
Pattern
Size

Hibernate
CompositionType
ConstraintComposition
CreditCardNumber
Email
Length
NotBlank
NotEmpty
Range
SafeHtml
ScriptAssert
URL

?

用法(在pojo定义中)

@Email(message = "邮件地址格式不正确")public String getEmail() {return email;}

?使用

//output the error informationSet<ConstraintViolation<Customer>> violations = validator.validate(customer);//throw the exceptionsValidatorUtils.validateWithException(validator, customer);
?

?