你会发现你只要写一个新的东西,或者想用ssm框架新的功能时,一般都会进行下面两步,导入需要的jar包和写配置文件,当然利用Hibernate Validator实现ssm的数据校验也不例外。
1、需要的jar包(注意各个jar之间可能存在版本不兼容)
hibernate-validator-5.0.0.CR2.jar classmate-0.8.0.jar jboss-logging-3.1.1.GA.jar
validation-api-1.1.0.CR1.jar hibernate-validator-annotation-processor-5.0.0.CR2.jar
链接:https://pan.baidu.com/s/1Ms0Frr4ZgSy6UJftozxkvA
提取码:tqjq
2、配置文件
我相信你如果学这个那么你的其它的配置文件一定写好了,那我将springmvc的配置文件写给大家,大家可以进行参考
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.2.xsd">
<!-- 将控制器所在包 加入IOC容器 -->
<context:component-scan base-package="org.library.controller,org.library.service.impl"></context:component-scan>
<!-- 配置视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/views/pages/"></property>
<property name="suffix" value=".jsp"></property>
<property name="order" value="2"></property>
</bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewNames" value="customer*"/>
<property