1 下载hibernate-validator包
2、在实体类方法上进行注解
3、在controller类的参数列表中进行valid注解
4、在页面中使用spring mvc的form标签输出错误
5、要使用form标签输出错误,需要在web.xml配置
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</context-param>