日期:2014-05-19  浏览次数:20737 次

spring国际化不能拦截.jsp的请求
applicationContext.xml中的核心这样配置的。
XML code
 <!-- 配置spring mvc 模式 -->
    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
        <property name="prefix"><value>/</value></property>
        <property name="suffix"><value>.jsp</value>
        </property>
    </bean>
    
   
    <!-- Register the welcome.properties -->
    <bean id="messageSource"
        class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <property name="basename" value="classpath:welcome" />
        <property name="defaultEncoding" value="UTF-8"/>
    </bean>
    <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.CookieLocaleResolver">
        <property name="defaultLocale" value="zh_CN" />
    </bean>    
    
    <bean id="handlerMapping"
        class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
        <property name="interceptors">
            <ref bean="localeChangeInterceptor" />
        </property>    
            
    </bean>
    


web.xml中核心配置:
XML code
<display-name>com.huawei.datavoice.web</display-name>

    <session-config>
        <session-timeout>20</session-timeout>
    </session-config>

    <!-- 实例化spring容器 -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
            <param-value>
                classpath:applicationContext.xml
            </param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>


    <!-- 使用spring处理字符集 -->
    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>*.do</url-pattern>
    </filter-mapping>

    <!-- 配置 springmvc 的servlet -->
    <servlet>
        <servlet-name>springmvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>


问题:
国际化只能拦截*.do 结尾的请求,如果是*.jsp结尾的国际化就不起作用了。应该要修改拦截器规则,本人没做spring国际化过,是在网上找的资料,这种问题不知如何解决,希望高手帮忙,谢谢!!!

------解决方案--------------------
严格的应用使用 .do 转发到 jsp 页面就可以了,没必要直接访问 jsp 页面,这样做安全性也不高。
------解决方案---------