Validate 종류들
With JSR-303, a single javax.validation.Validator
instance typically validates all model objects that declare validation constraints. To configure a JSR-303-backed Validator with Spring MVC, simply add a JSR-303 Provider, such as Hibernate Validator, to your classpath. Spring MVC will detect it and automatically enable JSR-303 support across all Controllers.
The Spring MVC configuration required to enable JSR-303 support is shown below:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <!-- JSR-303 support will be detected on classpath and enabled automatically --> <mvc:annotation-driven/> </beans>
With this minimal configuration, anytime a @Valid @Controller input is encountered, it will be validated by the JSR-303 provider. JSR-303, in turn, will enforce any constraints declared against the input. Any ConstaintViolations will automatically be exposed as errors in the BindingResult renderable by standard Spring MVC form tags.
참조 : http://docs.spring.io/spring/docs/3.0.0.RC3/reference/html/ch05s07.html
javax.validation.constraints.Digits
org.hibernate.validator.constraints.URL
org.hibernate.validator.constraints.NotEmpty
org.hibernate.validator.constraints.NotBlank
org.hibernate.validator.constraints.Length
org.hibernate.validator.constraints.Email
org.hibernate.validator.constraints.CreditCardNumber