首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

基于诠注的Spring2.5国际化配置

2012-06-28 
基于注解的Spring2.5国际化配置由于控制器是基于注解的?beans xmlnshttp://www.springframework.org/sc

基于注解的Spring2.5国际化配置

由于控制器是基于注解的

?

<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd                  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"><context:component-scan base-package="com.xx.pp.controller"></context:component-scan><bean id="messageSource"value="utf-8" /><property name="basenames"><list><value>WEB-INF/config/errorCode</value><value>WEB-INF/messages/messages</value></list></property></bean><bean id="localeChangeInterceptor"value="locale" /></bean><bean id="localeResolver"/><bean id="annotationMapper"/></list></property></bean></beans>
?

以上配置是最小配置

?

配置完成以后就可以通过url?locale=zh_CN这种方式进行语言切换了

?

localeResolver要用CookieLocaleResolver而不是AcceptHeaderLocaleResolver,若是后者则会抛出异常:
throw new UnsupportedOperationException(”Cannot change HTTP accept header - use a different locale resolution strategy”);

?

?

热点排行