JSR-303 Spring MVC 验证消息国际化 配置

本文中使用的个软件版本(见最下方截图):

Spring:4.1.1

JSR 303 Validator: 1.0.0

JSR 303 Validator实现:hibernate 4.3.2

说明:为什么这里选择hibernate 4.3.2,而没有选择更高版本?

原因:Hibernate Validator 4.X 版本是完全基于JSR303;5.X版本还实现了JSR349的特性。

What’s the difference between Hibernate Validator 3, 4 and 5?

Hibernate Validator 3.x and 4.x/5.x are different codebases.

Hibernate Validator is the original validation framework from the Hibernate team and is now referred to as "Legacy Hibernate Validator". 

Hibernate Validator 4.x is the reference implementation of Bean Validation 1.0 (JSR 303),while Hibernate Validator 5.x is the reference implementation of Bean Validation 1.1 (JSR 349). Active development happens on the 5.x codebase.


一、使用Hibernate Validator内置的国际化消息配置

1. 引入所需要的包

2. 配置

<mvc:annotation-driven />
3. 在需要验证的对象属性字段上用注解校验

<pre name="code" class="java">public class Application {
	privat
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值