【发布时间】:2012-04-24 06:15:39
【问题描述】:
我已将 Spring 配置 xml 配置为使用“ResourceBundleMessageSource”,并且我正在尝试从资源包文件中获取消息,但是当我要执行时,我得到的日志显示:找不到资源使用给定名称捆绑。
更精确:
WARN org.springframework.context.support.ResourceBundleMessageSource - ResourceBundle [messages] not found for MessageSource: Can't find bundle for base name messages, locale en_US
我对spring.xml的配置
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename">
<value>messages</value>
</property>
</bean>
我试图在我的代码中使用的方式:
ResourceBundleMessageSource rbms = (ResourceBundleMessageSource) applicationCtx.getBean("messageSource");
String message = rbms.getMessage("key001", parameters,"default message", null);
还有我的messages.properties的一部分(我已经把这个文件放在project/src/下)
key001 = Problem occurred while fetching the results from database. Please see log.
我也尝试使用 messages_en_US.properites 重命名文件,但没有帮助。
我错过了什么吗?
提前致谢。
【问题讨论】:
标签: java spring internationalization