雖然我嘗試重寫默認的Hibernate Validator消息但沒有成功。我已經使用了一些資源包,用於幾個文本,工作很好。問題出在Validator的消息上。覆蓋Hibernate驗證器消息
詳細:
我創建以下文件:ValidationMessages_de.properties並把它放在下的\ src \主\資源\翻譯\ ValidationMessages_de.properties。該文件具有以下資源: org.hibernate.validator.constraints.NotBlank.message =值是必需的。 org.hibernate.validator.constraints.NotEmpty.message =值爲必填項。
我faces-config.xml中有以下內容:
<application>
<locale-config>
<default-locale>de</default-locale>
<supported-locale>de</supported-locale>
</locale-config>
<resource-bundle>
<base-name>translations.messages</base-name>
<var>msg</var>
</resource-bundle>
<resource-bundle>
<base-name>translations.ValidationMessages</base-name>
<var>validMsgs</var>
</resource-bundle>
<message-bundle>
translations.ValidationMessages
</message-bundle>
</application>
爲了驗證我使用了以下注釋: @NotEmpty @NotBlank
我也試過以下:
- 將ValidationMessages_de.properties移動到另一個直接RY
- 創建一個ValidationMessages.properties作爲也是ValidationMessages_de_DE.properties
無的上述解決問題。驗證時,休眠讓我對德國語言環境的默認消息:DARF nicht閱讀盛
我缺少什麼?
什麼是描述在http://stackoverflow.com/questions/7093468/how-to-add-custom-error-messages-in-hibernate-validator和http://stackoverflow.com/questions/21630589/覆蓋 - 默認-hibernate-validator-messages與你的情況有所不同嗎? – Kukeltje
它在您的已部署的應用程序中 – Kukeltje
是的。 Primefaces客戶端驗證正在讀取此消息包中的文本,沒有任何問題。 Hibernate驗證器看起來有問題。 – Stephan