English 中文(简体)
@notBlank在 Bean 校验中失踪。 如何效法?
原标题:Missing @NotBlank in Bean Validation. How to emulate?

我迁移了一个应用程序, 该应用程序是用 Bean 校验的参考 Hibernate 执行。 本代码中使用了批注 < code_ nonBlank ( org.hibertate. validator.constraints. notBlank ) 。

然而,在我的新的Websphere 8容器中,有一个豆类验证执行捆绑在一起,我想使用。然而,似乎并不包含在Bean验证 API 中。

Any suggestions on how to emulate the tag with correct Bean Validation annotations? I guess something starting with: @NotNull@Size(min=1)

最佳回答

Hiberate 验证器 s nonBlank 是 < a href="http://docs.jboss.org/hibernate/stail/validator/ reference/en-US/html/validator-constableintrints.html#validator-constalstraints-compounds= rel=" noreferrer" > 组合约束 附加的注释 < a href=" https://github.com/hibernate/hibernate-validator/blob/5.1/engine/src/src/main/java/org/hibernate/validator/international/constrainvalidator/ NoteBlankValidator.java>\ rel=" noreferr> > a restrastrastrator < a > 。 此外 the contraffenderr >

问题回答

我不允许添加笔记, 所以这里有我给 Gunnar 的笔记 回答上面。 与 GitHub 的链接断了 。 这里有两个相关的地方 :

添加大小限制只会确保空的“ ” 字符串不会通过, 但像“ ” 这样的字符串将允许通过, 因为它们的大小大于1. 我正面临一个类似的问题。 我无法使用冬眠 s NotBlank 注释, 因为我的剧本是自动生成的 。 所以我使用了此选项 。

  regex=".*[S]+.*" 

which did the work for me . PS : For some reason * symbol is being accepted as comment alongwith (.)





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...