配置文件配置如下
名字必须是messageSource
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<!-- basenames确定资源文件的文件名,该属性接受list 值,用于接受多个资源文件-->
<property name="basenames">
<list>
<!--确定一份资源文件,资源文件名为message -->
<value>message</value>
<!-- 如果有多个资源文件,全部列在此处一-->
</list>
</property>
</bean>
新建几个.properties文件 将资源文件国际化使用native2ascii message_zh.properties message_zh_l.properties
调用方式
ApplicationContext context = new FileSystemXmlApplicationContext("applicationContext.xml");
String a[] = {"读者"};
String hello = context.getMessage("资源文件关键字",a( 要国际化的内容),Locale.getDefault()(选择语言默认中文));