1.springMVC配置多语言
spring-MVC.XML
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>classpath:Language/Language</value>
</list>
</property>
<property name="cacheSeconds" value="3600"/><!-- -1永不自动加载 -->
<!-- 如果在国际化资源文件中找不到对应代码的信息,就用这个代码作为名称 -->
<property name="useCodeAsDefaultMessage" value="true" />
</bean>
<!-- 国际化操作拦截器 如果采用基于(请求/Session/Cookie)则必需配置 -->
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<!-- <property name="defaultLocale" value="en_US"/> -->
</bean>
<mvc:interceptors>
<!--国际化资源切换(根据请求参数中的locale参数自动切换) -->
<mvc:interceptor>
<mvc:mapping path="/**" />
<ref bean="SystemInterceptor" />
</mvc:interceptor>
<mvc:interceptor>
<mvc:mapping path="/**" />
<ref bean="localeChangeInterceptor" />
</mvc:interceptor>
<mvc:interceptor>
<mvc:mapping path="/**" />
<ref bean="themeChangeInterceptor" />
</mvc:interceptor>
<!-- <mvc:interceptor> <mvc:mapping path="/**" /> <ref bean="SqlInjectInterceptor"/>
</mvc:interceptor> -->
</mvc:interceptors>
2.Language_zh_CN.xml
<!-- 页面验证 -->
<entry key="IsNoEmpty">不能为空</entry>
<entry key="OnlyNum">只能为数字</entry>
<entry key="Between">长度为{0}-{1}位</entry>
<entry key="IsBlank">不能包含空格</entry>
<entry key="IsMobile">手机号码格式不正确</entry>
<entry key="IsEmail">邮箱格式不正确</entry>
<entry key="IsConfirm">两次填写的密码不一致</entry>
<entry key="IpAddress">IP地址不正确</entry>
<entry key="onlyEnAndNum">输入英文、数字或下划线</entry>
<entry key="Length">长度为{0}-{1}</entry>
<entry key="Byte">位</entry>
<entry key="onlyInt">只能为数字</entry>
3.页面使用spring标签
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<spring:message code="Between" arguments="1,32" argumentSeparator=","/>
arguments属性为通配符匹配的值;
argumentSeparator属性为通配符是按照什么格式进行分割的。