Why won't work?

后端 未结 1 469
Happy的楠姐
Happy的楠姐 2021-01-18 20:06

I use JSF 2.0, hibernate-validator4.2.jar validation-api.jar tomcat and Eclipse.

I put @Size(min=3, message=\"xxx\") annotation in a @ManagedBean and

1条回答
  •  借酒劲吻你
    2021-01-18 20:35

    It should work perfectly fine, although the empty tag is entirely superfluous in this context. It's supposed to be used to "finetune" validation more, such as grouping of validation and/or disabling the implicit bean validation on a per-input basis by specifying the desired tag attributes. You have however no attributes on that tag, so just remove that tag altogether. On a default JSF 2 + JSR 303 project setup, it's supposed to kick in fully transparently without adding more JSF tags whenever there's a JSR 303 annotation on the property such as @Size and likes.

    But I don't think that removing the tag will solve this particular exception. Your problem lies thus deeper. This validator is supposed to be auto-registered on startup. However, the exception basically tells that the validator is not registered at all. With the information given so far, it's not possible to give a targeted answer. I can think of the following possible causes:

    1. There's a bug in the JSF implementation which you're using. Upgrade it to a newer version.
    2. You have multiple JSF libraries of different versions in your classpath. Cleanup it.
    3. The faces-config.xml root declaration is not declared conform JSF 2.x. Fix it.

    0 讨论(0)
提交回复
热议问题