利用Hibernate Validator实现ssm的数据校验

本文介绍了如何在SSM(Spring、Struts、MyBatis)框架中利用Hibernate Validator进行数据校验。首先,列举了所需的jar包,并提供了下载链接。接着,展示了配置文件中的Spring MVC配置部分,以注册教师为例详细阐述了数据校验的实施步骤。在实体类中通过注解定义校验规则,然后在Controller中实现校验逻辑。最后,提醒读者理解Hibernate Validator的工作原理,并推荐了相关的学习资源和讲师。
摘要由CSDN通过智能技术生成

你会发现你只要写一个新的东西,或者想用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 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

1029179954

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值