zoukankan      html  css  js  c++  java
  • 【问题记录】springmvc国际化问题

    异常-Cannot change HTTP accept header - use a different locale resolution strategy

    springmvc国际化时,locale resolution strategy的bean命名一定是localeResolver
    例如:

    <bean id="localeResolver"
            class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />

    中文乱码-解决从properties文件到jsp界面乱码问题

    <bean id="messageSource"
            class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
            <property name="basename" value="classpath:i18n/messages" />
            <property name="useCodeAsDefaultMessage" value="true" />
            <!-- 禁止在生产环境中使用它,开发可用 -->
            <property name="cacheSeconds" value="0" />  
            <!-- 解决从properties文件到jsp界面乱码问题 -->
            <property name="defaultEncoding" value="UTF-8"/>  
        </bean>

    中文乱码-解决前端到后台乱码问题

    <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>
            <init-param>
                <param-name>forceEncoding</param-name>
                <param-value>true</param-value>
            </init-param>
        </filter>
        <filter-mapping>
            <filter-name>encodingFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>

    注意jsp页面中的编码格式也要设置为UTF-8哦。

  • 相关阅读:
    使用AChartEngine画图,项目总结
    Windows系统安装实验报告
    Linux系统安装实验报告
    vm虚拟机详细安装步骤
    L3-010. 是否完全二叉搜索树
    第13届景驰-埃森哲杯广东工业大学ACM程序设计大赛
    L2-021. 点赞狂魔
    L2-020. 功夫传人
    L2-019. 悄悄关注
    L2-017. 人以群分
  • 原文地址:https://www.cnblogs.com/zeling/p/8494845.html
Copyright © 2011-2022 走看看