验证生成的JAXB类(JSR 303 / Spring)

编程入门 行业动态 更新时间:2024-10-25 19:31:48
本文介绍了验证生成的JAXB类(JSR 303 / Spring)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用JAXB(maven-jaxb2-plugin)从模式生成域对象(请求和响应) 我想为几个属性添加验证(notnull / empty)。我想有自定义Bean验证,应用程序是一个REST服务,我使用的是Spring 3和JSR 303 但我不认为我可以使用JSR 303验证对象,因为它是从模式生成的。

I Generated domain objects from schema (request & response) using JAXB (maven-jaxb2-plugin) I would like add validations (notnull /empty) for couple of attributes. I would like to have custom Bean Validation, the application is a REST service, i'm using Spring 3 and JSR 303 but i dont think i can use JSR 303 to validate the object as it is generated from the schema.

有人可以给我一个关于如何完成这项工作的正确方向。

can someone give me a nudge in the right direction on how to get this done.

推荐答案

我们一直在使用 Krasa JAXB插件来生成JSR来自XSD文件的303注释模型bean,然后告诉Spring 自动验证输入bean。如果你有很好的XSD,这会产生非常漂亮,非常简洁,非常干的代码。

We've been using the Krasa JAXB plugin to generate JSR 303-annotated model beans from XSD files, and then telling Spring to automatically validate the input beans. This results in very nice, very terse, very DRY code if you have good XSDs.

更多推荐

验证生成的JAXB类(JSR 303 / Spring)

本文发布于:2023-10-07 17:27:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1470023.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:JSR   JAXB   Spring

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!