Spring's support for internationalization is a new feature added to the Beanfactory subinterface ApplicationContext, mainly because the ApplicationContext interface inherits the Messagesource interface. The GetMessage (String code,object[] Obj,locale Locale) method of the Messagesource interface is used for internationalization support.
In spring's support for internationalization we need to configure in the context of the application:
<bean id= "Messagesource" class= "Org.springframework.context.support.RegourceBundleMessageSource" >
<property name= "Basenames" >
<list>
<value>message</value>//indicates that our resource file basename is a message, the default path of the resource file is under the SRC path, if we want to put the resource file under test, then <value >test/message</value>
</list>
</property>
</bean>
Create a resource file message_zh_cn.properties hello= Hello {0}
Message_en_us.properties hello=hello{0}
We can go through ApplicationContext ac=new classpathxmlapplicationcontext (...);
String hello=ac.getmessage ("Hello", New string[]{"HI"},locale.getdefault (Category.format));
You can get the value of hello in this locale
Spring Internationalization support