同时使用JSR-303和传统Bean验证吗? [英] Using both JSR-303 and Traditional Bean Validation?

查看:127
本文介绍了同时使用JSR-303和传统Bean验证吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以同时使用 JSR-303 bean验证传统验证(单个验证器类的类型)在春季?如果是这样,设置此设置需要什么配置?

Is it possible to use both JSR-303 bean validation and traditional validation (a single validator class for the type) in Spring? If so, what configuration is required to set this up?

我已经尝试过

我可以使用我的自定义Validator JSR-303验证,但不能同时使用两者.如果我在示例中有initBinder,它将使用自定义Validator.如果删除它,则会使用JSR-303 bean验证.我如何同时使用?

I can get this to use my custom Validator or the JSR-303 validation, but not both. If I have the initBinder present as in the example it uses the custom Validator. If I remove it the JSR-303 bean validation is used. How can I use both?

推荐答案

我已按照此处的说明进行了此操作:

I've done that following the instructions here:

http://blog .jteam.nl/2009/08/04/bean-validation-integrating-jsr-303-with-spring/

请参阅两全其美"部分.不久,您将通过Spring验证器显式运行JSR303验证,并基于注释和您的自定义验证逻辑联接" JSR303验证的结果.

See the "Enjoy both worlds" section. Shortly, you explicitly run a JSR303 validation from a Spring validator, "joining" the results of JSR303 validations based on annotations and your custom validation logic.

这篇关于同时使用JSR-303和传统Bean验证吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆