Click here to load reader
Upload
sewon-ann
View
8.777
Download
3
Embed Size (px)
Citation preview
2.
JSR 303 (Bean Validation)
JSR 303
JSR 303
Spring 3 JSR 303
Spring 3 JSR 303
Spring MVC JSR 303
2
3. (Validation)
, !
Validation
if( input.getName() == null ||
input.getAddress() == null ||
input.getEmail() == null ) { throw new
Exception(invalid input!);}
3
4. JSR 303 Bean Validation
Java
< >[1]
[1] Hibernate Validator Reference Guide
4
5.
5
< Application- ValidateCar>
!!
doors:must be greater than or equal to 2
name:may not be null
< Car>
6. JSR 303 4
6
7. Constraint Annotation
8. ) 9. 10. 11. 12. 13. Bean (Property) (getter ) 14. ) !7
15. Constraint Annotation
16. Retention:RUNTIME 17. Constraint: validatedBy Constraint
Validation 18. message(): . annotation fully qualified class name +
.message 19. groups(): 20. payload(): @Past [1]
[1] JSR 303 Spec
8
21. Constraint Annotation
9
22. Constraint Validation
Constraint Annotation @Constraint( validatdateBy )
Constraint Annotation , Class
) @Past Hibernate
Validatororg.hibernate.validator.constraints.impl.PastValidatorForCalendar
org.hibernate.validator.constraints.impl.PastValidatorForDate
10
23. Constraint Validation
11
24. Constraint Annotation, 25. initialize(): . 26. ) annotation field 27. isValid() : , boolean . ConstraintViolation ConstraintValidatorContext