1.hibernate的校验框架validation所需要jar包
![](https://i-blog.csdnimg.cn/blog_migrate/081f52f00ef1742a3960459b75c45b5c.png)
2.spring-mvc.xml添加validator配置
<mvc:annotation-driven validator="validator"></mvc:annotation-driven>
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="providerClass" value="org.hibernate.validator.HibernateValidator"></property>
<property name="validationMessageSource" ref="messageSource" />
</bean>
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>classpath:val