Based on the SPRINGMVC International Resource allocation method.
1. First, you need to configure the interceptor in Spring-mvc-servlet.xml;
<bean id= "Localechangeinterceptor" class= "Org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/>
2. If you want browser adaptive language (cookie mode): Also need to be configured in Spring-mvn-servlet.xml:
2.1
<bean id= "Cookielocaleresolver" class= "Org.springframework.web.servlet.i18n.CookieLocaleResolver"/>
2.2. If you need to switch on the interface (session mode), then you need to configure:
<bean id= "Localeresolver" class= "Org.springframework.web.servlet.i18n.SessionLocaleResolver" > < Property Name= "Defaultlocale" value= "en_US"/> </bean>
3. Finally configure the resource file in Applicationcontext.xml
<bean id= "Messagesource" class= "Org.springframework.context.support.ResourceBundleMessageSource" > < Property Name= "basename" value= "message"/> <property name= "Usecodeasdefaultmessage" value= "true"/> </bean>
4. Configure Local in the interceptor with the following code:
<mvc:interceptors> <!--International Resource switching (automatically switched based on the locale parameter in the request parameters)-- <mvc:interceptor> < Mvc:mapping path= "/**"/> <ref bean= "Localechangeinterceptor"/> </mvc:interceptor> </mvc:interceptors>
5. Specific message_zh_cn.properties, message_en_us.properties, and other documents, placed under Classpath.
Based on SPRINGMVC International Resource allocation method