0

アプリのメッセージを保持するために ValidationMessages.properties を使用したくありません。他のすべてが使用するものを使用したい: LabelNames.properties.

それができる方法はありますか?

4

2 に答える 2

0

可能です。ResourceBundleMessageInterpolatorとその bundle locator APIを使用できます。カスタム バンドル名は次のように指定できます。

Validator validator = 
   Validation.byProvider(HibernateValidator.class)
      .configure()
      .messageInterpolator(
         new ResourceBundleMessageInterpolator(
            new PlatformResourceBundleLocator( "LabelNames" )))
      .buildValidatorFactory()
      .getValidator();
于 2013-06-05T19:39:13.620 に答える