springmvc國際化的準備工做:java
一、在xml文件內進行配置web
<!-- 存儲區域設置信息 --> <bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver" /> <!-- 國際化資源文件 --> <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource" p:basename="webp/WEB-INF/resource/messages"/> <mvc:interceptors> <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"> <property name="paramName" value="lang" /> </bean> </mvc:interceptors>
二、增長配置文件以及在.jsp頁面引入標籤spring
.properties文件mvc
messages_en_US.properties和messages_zh_CN.properties文件設置響應的key value鍵值對jsp
頁面文件code
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<spring:message code="language.cn" />其中code即爲properties文件中的key,不一樣的properties文件有不一樣的value值。經過<spring:message />來獲取響應的code對應的value<spring:message code="operator"/>