我在项目EgovFramework上使用Spring时出现多语言问题。
当我请求http://localhost:8080/common/cop/adb/selectAdbkList.do?language=en_us时,我的问题无法改变语言,应该将所有标签和按钮名称更改为英语。
这是我的代码context-common.xml,用于调用文件消息
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="language" />
</bean>
<!-- <bean id="localeResolver" -->
<!-- class="org.springframework.web.servlet.i18n.SessionLocaleResolver"
/> -->
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="defaultLocale" value="ko_KR" />
</bean>
<bean id="handlerMapping"
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
<ref bean="localeChangeInterceptor" />
</property>
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>classpath:egovframework/message/com/messages</value>
</list>
</property>
<property name="fallbackToSystemLocale" value="false" />
<property name="cacheSeconds" value="3" />
<property name="defaultEncoding" value="UTF-8" />
<property name="fileEncodings" value="UTF-8" />
</bean>
<!-- <bean id="messageSource" -->
<!-- class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> -->
<!-- <property name="basenames"> -->
<!-- <list> -->
<!-- <value>classpath:/egovframework/message/com/message-common -->
<!-- </value> -->
<!-- </list> -->
<!-- </property> -->
<!-- <property name="defaultEncoding" value="UTF-8" /> -->
<!-- <property name="cacheSeconds"> -->
<!-- <value>60</value> -->
<!-- </property> -->
<!-- </bean> -->
<bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<array>
<value>classpath:/egovframework/egovProps/globals.properties
</value>
<value>classpath:/egovframework/rte/fdl/property/messages/properties.properties
</value>
<value>classpath:/egovframework/rte/fdl/idgnr/messages/idgnr.properties
</value>
</array>
</property>
</bean>
<bean id="egovMessageSource" class="egovframework.com.cmm.EgovMessageSource">
<property name="reloadableResourceBundleMessageSource">
<ref bean="messageSource" />
</property>
</bean>
<!-- 실행환경에서 빈 이름 참조(AbstractServiceImpl) -->
<bean id="leaveaTrace" class="egovframework.rte.fdl.cmmn.trace.LeaveaTrace">
<property name="traceHandlerServices">
<list>
<ref bean="egov.traceHandlerService" />
</list>
</property>
</bean>
<bean id="egov.traceHandlerService"
class="egovframework.rte.fdl.cmmn.trace.manager.DefaultTraceHandleManager">
<property name="reqExpMatcher">
<ref bean="egov.antPathMater" />
</property>
<property name="patterns">
<list>
<value>*</value>
</list>
</property>
<property name="handlers">
<list>
<ref bean="egov.defaultTraceHandler" />
</list>
</property>
</bean>
<bean id="egov.antPathMater" class="org.springframework.util.AntPathMatcher" />
<bean id="egov.defaultTraceHandler"
class="egovframework.rte.fdl.cmmn.trace.handler.DefaultTraceHandler" />
<!-- MULTIPART RESOLVERS -->
<!-- regular spring resolver -->
<bean id="spring.RegularCommonsMultipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="100000000" />
<property name="maxInMemorySize" value="100000000" />
</bean>
<!-- custom multi file resolver -->
<bean id="local.MultiCommonsMultipartResolver" class="egovframework.com.cmm.web.EgovMultipartResolver">
<property name="maxUploadSize" value="100000000" />
<property name="maxInMemorySize" value="100000000" />
</bean>
<!-- choose one from above and alias it to the name Spring expects -->
<!-- alias name="local.MultiCommonsMultipartResolver" alias="multipartResolver"
/ -->
<alias name="spring.RegularCommonsMultipartResolver" alias="multipartResolver" />
<context:component-scan base-package="egovframework, example">
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Service" />
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Repository" />
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
以下是所有文件消息的类路径。
请帮助我,为什么我要求时无法更改?language = en_us on browser .....
由于
答案 0 :(得分:1)
我不知道项目EgovFramework,但是对于普通的Spring,您应该在配置中使用此更改语言:
<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" p:paramName="language" />
</mvc:interceptors>
然后接缝是另一个错误:你使用了不同的外壳:
该文件名为(正确)messages_en_US.properties
。但是你尝试了?language=en_us
。请改为?language=en_US
。