【发布时间】:2014-08-04 14:46:07
【问题描述】:
我是 spring 的新手,现在我正在尝试使用 aplicationContext 执行 I18N 进程。我正在使用一个 Maven 模块化项目。我的项目包括以下子模块:
model-myApp 服务-myApp webApp-myApp
services-MyApp
src/main/java
src/main/resources
在 services-myApp 资源文件夹中,我用消息源声明了应用程序上下文
<!-- Need to I18N -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="WEB-INF/lang/myFile"/>
</bean>
在 webApp 中,我有 I18N 所需的文件
webApp-MyApp src/main/webapp/WEB-INF/lang/myFile_it_IT.properties
现在当我尝试获取消息时:
String message = applicationContext.getMessage("myCode", null,null, Locale.ITALY);
我反而得到了
警告 ResourceBundleMessageSource - 找不到 MessageSource 的 ResourceBundle [/WEB-INF/lang/myFile]:找不到基本名称 /WEB-INF/lang/myFile 的包,语言环境 it_IT
并且消息为空。而如果我在 webApp 类路径 (/src/main/resources) 中移动文件并将 messageSource 的值更改为 myFile 一切正常。
我该如何解决?
【问题讨论】: