Spring 3의 jsr 303 지원

Click here to load reader

download Spring 3의 jsr 303 지원

of 36

Transcript of Spring 3의 jsr 303 지원

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

  • Target: 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

  • javax.validation.ConstraintValidator

24. Constraint Annotation, 25. initialize(): . 26. ) annotation field 27. isValid() : , boolean . ConstraintViolation ConstraintValidatorContext