2013-06-05 62 views

回答

0

这是可能的。您可以使用ResourceBundleMessageInterpolator及其捆绑定位器API。

Validator validator = 
    Validation.byProvider(HibernateValidator.class) 
     .configure() 
     .messageInterpolator(
     new ResourceBundleMessageInterpolator(
      new PlatformResourceBundleLocator("LabelNames"))) 
     .buildValidatorFactory() 
     .getValidator(); 
+0

我该把这个放在哪里?我可以把这个放在启动课上,还是我误解了一些东西?我正在使用Spring MVC,所以我不使用Validator对象... – markthegrea

0

当与弹簧工作,从LocalValidatorFactoryBeanMessageSource用于所需束如this answer描述:自定义包名称可以像来指定。