zoukankan      html  css  js  c++  java
  • [转载]spring使用PropertyPlaceholderConfigurer加载properties文件处理中文乱码

    在spring中我们常常使用.properties对一些属性进行一个提前配置,spring在读取∗.properties文件时,默认使用的是asci码,这时我们需要对其编码进行转换.当然方法有很多种,我说以下几种

    1.spring.xml,.properties使"utf8"

    <context:property-placeholder location="classpath:conf/*.properties" file-encoding="UTF-8"/>

    2.使:

    @Component
    @PropertySource(value = "classpath:conf/copyWriteUI.properties",encoding = "utf-8")
    @Getter
    public class CopyWriteUI {
        @Value("${a}")
        private String a;
        @Value("${b}")
        private String b;
        }

    转自:http://blog.csdn.net/j3oker/article/details/53839210

    3.使用PropertyPlaceholderConfigurer配置编码格式

    <bean id="resourceConfigurer"
           class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:/config.properties</value>
                    <value>classpath:/send.properties</value>
                </list>
            </property>
            <property name="fileEncoding">
                <value>UTF-8</value>
            </property>
        </bean>
  • 相关阅读:
    Swift
    ios中沙盒
    Mac下安装apk(命令形式)
    iOS 保存异常日志
    android sliding menu
    iOS 苹果官方 Crash文件分析方法 (iOS系统Crash文件分析方法)
    iOS应用崩溃日志分析
    iOS 推送
    iOS 修改textholder的颜色
    iOS 7.1 UITapGestureRecognizer 不好用的解决办法
  • 原文地址:https://www.cnblogs.com/wendelhuang/p/7211966.html
Copyright © 2011-2022 走看看