2014-02-07 99 views
8

我想在一台服务器来覆盖默认的Hibernate验证消息面的Web应用程序,所以我阅读文档的这一部分:https://docs.jboss.org/hibernate/validator/5.0/reference/en-US/html/chapter-message-interpolation.html#section-message-interpolation改写默认Hibernate验证消息

我创建了src/文件夹内的两个文件:ValidationMessages.propertiesValidationMessages_de_DE.properties 。该文件的内容是:

javax.validation.constraints.AssertFalse.message = must be false 
javax.validation.constraints.AssertTrue.message = must be true 
javax.validation.constraints.DecimalMax.message = must be less than ${inclusive == true ? 'or equal to ' : ''}{value} 
javax.validation.constraints.DecimalMin.message = must be greater than ${inclusive == true ? 'or equal to ' : ''}{value} 
javax.validation.constraints.Digits.message  = numeric value out of bounds (<{integer} digits>.<{fraction} digits> expected) 
javax.validation.constraints.Future.message  = must be in the future 
javax.validation.constraints.Max.message   = must be less than or equal to {value} 
javax.validation.constraints.Min.message   = must be greater than or equal to {value} 
javax.validation.constraints.NotNull.message  = may not be null 
javax.validation.constraints.Null.message  = must be null 
javax.validation.constraints.Past.message  = must be in the past 
javax.validation.constraints.Pattern.message  = must match "{regexp}" 
javax.validation.constraints.Size.message  = size must be between {min} and {max} 

org.hibernate.validator.constraints.CreditCardNumber.message = invalid credit card number 
org.hibernate.validator.constraints.Email.message   = not a well-formed email address 
org.hibernate.validator.constraints.Length.message   = length must be between {min} and {max} 
org.hibernate.validator.constraints.NotBlank.message   = may not be empty 
org.hibernate.validator.constraints.NotEmpty.message   = may not be empty 
org.hibernate.validator.constraints.Range.message   = must be between {min} and {max} 
org.hibernate.validator.constraints.SafeHtml.message   = may have unsafe html content 
org.hibernate.validator.constraints.ScriptAssert.message  = script expression "{script}" didn't evaluate to true 
org.hibernate.validator.constraints.URL.message    = must be a valid URL 
org.hibernate.validator.constraints.br.CNPJ.message   = invalid Brazilian corporate taxpayer registry number (CNPJ) 
org.hibernate.validator.constraints.br.CPF.message   = invalid Brazilian individual taxpayer registry number (CPF) 
org.hibernate.validator.constraints.br.TituloEleitor.message = invalid Brazilian Voter ID card number 

我使用德语版本的Windows,所以邮件默认为德文。创建文件后,他们应该用英文,但他们仍然在德国。

我在做什么错?

回答

8

好的,正确的文件夹是/src/main/java/

+10

如果你正在使用maven,它应该是*/src/main/resources *,因为*/src/main/java *是针对java文件的。 – Zilvinas