2012-03-26 103 views
1

我想修改默认ValidationMessages.properties到其他。但我不明白。如何使用Hibernate验证器更改ValidationMessages.properties?

我的设置:

在春天。

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> 
    <property name="basenames"> 
     <list> 
      <value>text</value> 
      <value>error</value> 
     </list> 
    </property> 
</bean> 

<bean name="validator" 
     class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"> 
    <property name="validationMessageSource"> 
     <ref bean="messageSource"/> 
    </property> 
</bean> 

在text.properties和tex_XX.properties。

edit.profile.password.size=Password must be between {min} and {max} 

注释示例。

@Size(min=4, max=8, message="{edit.profile.password.size}") 

回答

0

即使您使用不同的验证提供程序,也应该在类路径上使用Hibernate Validator 4.1或更高版本。

相关问题