5. servlet-context.xml 파일에 유효성 검사 관련 빈을 설정합니다.
코드13-22 servlet-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans...>
...
<annotation-driven enable-matrix-variables="true" validator="validator"/> ➊
...
<beans:bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<beans:property name="basename" value="messages"/>
<beans:property name="defaultEncoding" value="UTF-8"/>
</beans:bean>
<beans:bean id="validator"
➋
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<beans:property name="validationMessageSource" ref="messageSource"/>
</beans:bean>
<beans:bean id="unitsInStockValidator"
class="com.springmvc.validator.UnitsInStockValidator"/> ➌
➍
<beans:bean id="bookValidator" class="com.springmvc.validator.BookValidator">
<beans:property name="springValidators">
<beans:set>
<beans:ref bean="unitsInStockValidator"/>
</beans:set>
</beans:property>
</beans:bean>
</beans:beans...>