i18n不支持spring mvc和tiles

i18n不支持spring mvc和tiles,spring,Spring,上面是我的SpringServletXML文件。。在我的jsp中使用它 <?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:aop="http://www.springframework.or

上面是我的SpringServletXML文件。。在我的jsp中使用它

<?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:aop="http://www.springframework.org/schema/aop"
            xmlns:context="http://www.springframework.org/schema/context"
            xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
            xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
                http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
                http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">

            <context:component-scan base-package="in.controllers" />

            <context:annotation-config />

            <!-- This tag adds DefaultAnnotationHandlerMapping. If <mvc:resources /> 
                is tag is used, it will add the ResourceHttpRequestHandler, which will break 
                the existing default handlers added by the spring. So it is required to add 
                the handler mapping explicitly or add <mvc:annotation-driven /> tag. -->
            <mvc:annotation-driven />

            <mvc:resources location="/static/" mapping="/static/**" />

            <!-- <bean id="viewNameTranslator" -->
            <!-- class="org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator" 
                /> -->

        <!--        If you do not register any “localeResolver”, the default AcceptHeaderLocaleResolver will be used,  -->
        <!--        which resolves the locale by checking the accept-language header in the HTTP request. -->

            <bean id="multipartResolver"
                class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />

            <bean id="viewResolver"
                class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <!--        <property name="order" value="0" /> -->
                <property name="viewClass"
                    value="org.springframework.web.servlet.view.tiles3.TilesView" />
            </bean>
            <bean id="tilesConfigurer"
                class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
                <property name="definitions" value="/WEB-INF/tiles-defs.xml" />
            </bean>
            <!-- for bilingual ..these are the settings ....starts... -->

            <bean id="messageSource"
                class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
                <property name="basename" value="/WEB-INF/messages/messages" />
                <property name="defaultEncoding" value="UTF-8" />
            </bean>

            <bean id="localeChangeInterceptor"
                class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
                <property name="paramName" value="locale"></property>
            </bean>

            <bean id="localeResolver"
                class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
                <property name="defaultLocale" value="kan"></property>
            </bean>

            <!-- the “order” property, where the lower order value has the higher priority. -->
            <bean id="handlerMapping"
                class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
        <!--        <property name="order" value="1" /> -->
                <property name="interceptors">
                    <ref bean="localeChangeInterceptor"></ref>
                </property>
            </bean>
            <!-- for bilingual ..these are the settings ....ends... -->
        </beans>


i18n不工作..请帮助..所有消息属性文件都存在..但i18n仍不工作..请帮助..

您可以更改块代码:

<a href="?locale=en">English</a> <a href="?locale=kan">   

使用以下代码:

<bean id="localeChangeInterceptor"
      class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
           <property name="paramName" value="locale"></property>
</bean>

<bean id="localeResolver"
    class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
    <property name="defaultLocale" value="kan"></property>
</bean>
<!-- the “order” property, where the lower order value has the higher priority. -->
<bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
    <!--        <property name="order" value="1" /> -->
    <property name="interceptors">
         <ref bean="localeChangeInterceptor"></ref>
    </property>
</bean>


移除
把手映射
它会破坏东西。您正在使用
然后使用
注册拦截器。您的建议解决了问题。。。。。非常感谢你…你救了我一天…非常感谢你。。。
<!-- Define locale resolver -->
<bean id="localeResolver"
        class="org.springframework.web.servlet.i18n.SessionLocaleResolver"
        p:defaultLocale="kan" p:cookieName="languageSession" />
<!-- Register the interceptors -->
<mvc:interceptors>
    <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" p:paramName="locale"/>
</mvc:interceptors>