1、刚开始搜网上一堆Spring-mvc配置,实则一点都不需要,反而容易纠结配置是否正确,离目的地越来越远
2、@Validated 和 @Valid也不要管他们两,这又是一堆坑人层热度,SSM框架中只能用@Validated
3、pom.xml中只需要引入两个包即可,无效其他不相干包,除非你要用EL表达式,但是我这里只给大家标出最简方案
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.2.4.Final</version>
</dependency>