两个实现:
org.springframework.context.support.ResourceBundleMessageSource
org.springframework.context.support.ReloadableResourceBundleMessageSource
查找顺序:自动在CLASSPATH根路径中按如下顺序搜寻国际化资源文件并加载(以Locale=zh_CN为例)
messages_zh_CN.properties
messages_zh.properties
messages.properties
messages_zh_CN.class
messages_zh.class
messages.class
配置示例
使用示例:
ApplicationContext appContext = new FileSystemXmlApplicationContext("bean.xml");
Object[] args = new Object[]{"xiaocao000", Calendar.getInstance().getTime()};
String i18n = appContext.getMessage("welcomeinfo",args,Locale.getDefault());
Unicode转码:
native2ascii -reverse -encoding utf8 inputfile outputfile
参考 [url]http://xiaocao000.iteye.com/admin/blogs/452612 [/url]
org.springframework.context.support.ResourceBundleMessageSource
org.springframework.context.support.ReloadableResourceBundleMessageSource
查找顺序:自动在CLASSPATH根路径中按如下顺序搜寻国际化资源文件并加载(以Locale=zh_CN为例)
messages_zh_CN.properties
messages_zh.properties
messages.properties
messages_zh_CN.class
messages_zh.class
messages.class
配置示例
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<description>Spring Quick Start</description>
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>messages</value>
</list>
</property>
</bean>
</beans>
使用示例:
ApplicationContext appContext = new FileSystemXmlApplicationContext("bean.xml");
Object[] args = new Object[]{"xiaocao000", Calendar.getInstance().getTime()};
String i18n = appContext.getMessage("welcomeinfo",args,Locale.getDefault());
Unicode转码:
native2ascii -reverse -encoding utf8 inputfile outputfile
参考 [url]http://xiaocao000.iteye.com/admin/blogs/452612 [/url]