我正在尝试将I18n应用于现有的Spring 2.5应用程序。以下是application-context.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName">
<value>SYSTEM_PROPERTIES_MODE_OVERRIDE</value>
</property>
<property name="locations">
<list>
<value>
classpath:Classification-System.properties
</value>
</list>
</property>
</bean>
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="defaultEncoding" value="UTF-8"/>
<property name="basenames">
<list>
<value>
classpath:classification/Strings
</value>
</list>
</property>
</bean>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="en_US" />
</bean>
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" >
<property name="interceptors">
<list>
<ref bean="localeChangeInterceptor" />
</list>
</property>
</bean>
</beans>
如果我登录应用程序,如果我为网址应用lang = es_ES,它只显示英语语言环境字符串,尽管语言环境是西班牙语 我在src / resouce /的分类文件夹中使用公共密钥和不同的值配置了Strings.properties,Strings_es_ES.properties,Strings_en_GB.properties。
你能帮助我吗?
我的web.xml是
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
version="2.4">
<filter>
<filter-name>openSessionInView</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>classificationSessionFactory</param-value>
</init-param>
<init-param>
<param-name>flushMode</param-name>
<param-value>AUTO</param-value>
</init-param>
</filter>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:application-context.xml</param-value>
</context-param>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>classifierweb</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>
com.opensymphony.module.sitemesh.filter.PageFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>openSessionInView</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>*.html</url-pattern>
</filter-mapping>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>classifierweb</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
你能帮助我吗?
这里是classifierweb-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<bean
class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
<property name="defaultHandler" ref="defaultController" />
</bean>
<bean id="defaultController"
class="com.billshrink.ml.classification.web.controller.DefaultController"></bean>
<bean id="classificationController"
class="com.billshrink.ml.classification.web.controller.ClassificationController">
<property name="sessionFactory" ref="classificationSessionFactory" />
<property name="classificationDao" ref="classificationDao" />
<property name="classifier" ref="classifier" />
<property name="classificationExportable" ref="classificationExportable" />
<property name="dataSources">
<list>
<ref bean="merchantsClassificationExpressionDataSource" />
<ref bean="categoryClassificationExpressionDataSource" />
<ref bean="cityStateClassificationExpressionDataSource" />
<ref bean="ageRangeClassificationExpressionDataSource" />
<ref bean="priceRangeClassificationExpressionDataSource" />
<ref bean="nationalityClassificationExpressionDataSource" />
<ref bean="chunkedMerchantsClassificationExpressionDataSource" />
<ref bean="chunkedCategoryClassificationExpressionDataSource" />
<ref bean="chunkedCityStateClassificationExpressionDataSource" />
<ref bean="chunkedAgeRangeClassificationExpressionDataSource" />
<ref bean="chunkedPriceRangeClassificationExpressionDataSource" />
<ref bean="chunkedNationalityClassificationExpressionDataSource" />
<ref bean="chunkedChannelClassificationExpressionDataSource" />
<ref bean="merchantChannelExpressionDataSource" />
<ref bean="chunkedPhoneGeoClassificationExpressionDataSource" />
<ref bean="chunkedTransactionTypeClassificationExpressionDataSource" />
<ref bean="phoneGeoClassificationExpressionDataSource" />
<ref bean="transactionTypeClassificationExpressionDataSource" />
<ref bean="cityExpressionDataSource" />
<ref bean="stateExpressionDataSource" />
<ref bean="merchantCategoryExpressionDataSource" />
<ref bean="channelClassificationExpressionDataSource" />
<ref bean="chunkedLocationBasedMerchantExpressionFilter" />
<ref bean="chunkedCategoryExpressionFilter" />
<ref bean="chunkedCityStateCategoryExpressionFilter" />
<ref bean="chunkedAgeRangeExpressionFilter" />
<ref bean="chunkedPriceRangeExpressionFilter" />
<ref bean="chunkedNationalityExpressionFilter" />
<ref bean="chunkedChannelExpressionFilter" />
<ref bean="chunkedPhoneGeoCategoryExpressionFilter"/>
<ref bean="chunkedTransactionTypeCategoryExpressionFilter"/>
</list>
</property>
<property name="luceneUtil" ref="luceneUtil" />
<property name="cacheManager" ref="classificationCacheManager" />
<property name="displayNames">
<bean class="org.springframework.beans.factory.config.MapFactoryBean">
<property name="sourceMap">
<map>
<entry key="type" value="Type" />
<entry key="dimension" value="Dimension" />
<entry key="name" value="Name" />
<entry key="displayName" value="Display Name" />
<entry key="searchExpression" value="Search Expression" />
<entry key="phoneNumbers" value="Phone Numbers" />
<entry key="areaCodes" value="Area Codes" />
<entry key="CATEGORY" value="Category" />
<entry key="AGE_RANGE" value="Age Range" />
<entry key="PRICE_RANGE" value="Price Range" />
<entry key="NATIONALITY" value="Nationality" />
<entry key="LOCATION_TYPE" value="Location Type" />
<entry key="CHANNEL" value="Channel" />
<entry key="TRANSACTION_TYPE" value="Transaction Type" />
<entry key="zips" value="Zips" />
</map>
</property>
</bean>
</property>
<property name="displayAttributes">
<map>
<entry key="CITY_STATE">
<bean class="org.springframework.beans.factory.config.ListFactoryBean">
<property name="sourceList">
<list>
<value>zips</value>
</list>
</property>
</bean>
</entry>
</map>
</property>
<property name="displayDimensions">
<map>
<entry key="MERCHANT">
<bean class="org.springframework.beans.factory.config.ListFactoryBean">
<property name="sourceList">
<list>
<value>CATEGORY</value>
<value>AGE_RANGE</value>
<value>PRICE_RANGE</value>
<value>NATIONALITY</value>
<value>LOCATION_TYPE</value>
<value>CHANNEL</value>
</list>
</property>
</bean>
</entry>
</map>
</property>
<property name="attributeNames">
<map>
<entry key="phoneNumbers" value="phoneNumber" />
<entry key="areaCodes" value="areaCode" />
<entry key="ageRange" value="ageRange" />
<entry key="priceRange" value="ageRange" />
<entry key="nationality" value="nationality" />
<entry key="zips" value="zips" />
</map>
</property>
<property name="metaDataDimensions">
<list>
<value>CATEGORY</value>
<value>AGE_RANGE</value>
<value>PRICE_RANGE</value>
<value>NATIONALITY</value>
<value>LOCATION_TYPE</value>
<value>CHANNEL</value>
</list>
</property>
</bean>
<bean
class="com.billshrink.ml.classification.web.controller.TransactionController">
<property name="classifier" ref="classifier" />
<property name="classificationDao" ref="classificationDao" />
<property name="tokenNames" ref="tokenNames" />
<property name="classifiedTokenNames" ref="classifiedTokenNames" />
</bean>
<bean id="tokenNames" class="org.springframework.beans.factory.config.MapFactoryBean">
<property name="sourceMap">
<map>
<entry key="merchant" value="Merchant" />
<entry key="phoneNumber" value="Phone Number" />
<entry key="location" value="Location" />
<entry key="city" value="City" />
<entry key="state" value="State" />
</map>
</property>
</bean>
<bean id="classifiedTokenNames" class="org.springframework.beans.factory.config.MapFactoryBean">
<property name="sourceMap">
<map>
<entry key="MERCHANT" value="Merchant" />
<entry key="zips" value="Zip" />
<entry key="city" value="City" />
<entry key="state" value="State" />
<entry key="CITY_STATE" value="City State" />
<entry key="CATEGORY" value="Category" />
<entry key="AGE_RANGE" value="Age Range" />
<entry key="PRICE_RANGE" value="Price Range" />
<entry key="NATIONALITY" value="Nationality" />
<entry key="CHANNEL" value="Channel" />
<entry key="TRANSACTION_TYPE" value="Transaction Type" />
</map>
</property>
</bean>
<bean
class="com.billshrink.ml.classification.web.controller.ClassificationMonitorController">
<property name="db" ref="classificationMonitorDb" />
</bean>
<bean
class="com.billshrink.ml.classification.web.controller.TokenizerController">
<property name="tokenizer" ref="transactionTokenizer" />
<property name="tokenNames" ref="tokenNames" />
</bean>
<bean class="com.billshrink.ml.classification.web.controller.FeedsController">
<property name="classificationDao" ref="classificationDao" />
<property name="classificationController" ref="classificationController" />
</bean>
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="10000000" />
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="defaultEncoding" value="UTF-8"/>
<property name="basenames">
<list>
<value>
classpath:classification/Strings
</value>
</list>
</property>
</bean>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="en_US" />
</bean>
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" >
<property name="interceptors">
<list>
<ref bean="localeChangeInterceptor" />
</list>
</property>
</bean>
</beans>