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>
  • 相关阅读:
    NoSQL数据库:Java开源项目Neo4j简介
    EPOLL和IOCP比较
    CString&CStringA&CStringW之间的相互转换
    CString和CStringA之间的转换
    Windows IOCP模型与Linux EPOLL模块之比较
    OCP-1Z0-053-V13.02-708题
    OCP-1Z0-053-V13.02-709题
    OCP-1Z0-053-V12.02-342题
    OCP-1Z0-053-V12.02-341题
    OCP-1Z0-053-V13.02-706题
  • 原文地址:https://www.cnblogs.com/wendelhuang/p/7211966.html
Copyright © 2011-2022 走看看