春季:基于MessageSource获取ResourceBundle
时间:2020-03-06 15:05:07 来源:igfitidea点击:
我在Spring中使用了休眠验证器框架。实现Spring Validator的类使用Hibernate的ClassValidator验证对象。为了本地化ClassValidator的错误消息,我需要将ResourceBundle传递到类的构造函数中。我的ApplicationCountext有一个MessageSource bean(ReloadableResourceBundleMessageSource),该bean在整个应用程序中使用。为ClassValidator使用相同的MessafeSource是有意义的。但是,如何将MessageSource转换为ResourceBundle?有适配器类吗?
解决方案
MessageSourceResourceBundle听起来像我们要找的东西。 (我自己还没有尝试过。)