글
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
'S > Spring' 카테고리의 다른 글
ContentNegotiatingViewResolver 와 ResponseBody 차이 (0) | 2014.07.15 |
---|---|
Spring - @ResponseBody 응답 시 한글 인코딩(깨짐) 문제 (0) | 2014.07.15 |
Request processing failed; nested exception is org.apache.tiles.definition.DefinitionsFactoryException: I/O Error reading definitions.] with root cause (0) | 2014.06.14 |
Binding a List Request Parameter on Spring MVC (0) | 2014.06.03 |
Spring form 태그 유의 사항 (0) | 2014.05.28 |