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>
  • 相关阅读:
    SPOJ ORDERSET
    BZOJ 1109: [POI2007]堆积木Klo
    BZOJ 1112: [POI2008]砖块Klo
    BZOJ 4144: [AMPPZ2014]Petrol
    BZOJ 4385: [POI2015]Wilcze doły
    BZOJ 1124: [POI2008]枪战Maf
    BZOJ 1123: [POI2008]BLO
    BZOJ 1121: [POI2008]激光发射器SZK
    BZOJ 1131: [POI2008]Sta
    BZOJ 4551: [Tjoi2016&Heoi2016]树
  • 原文地址:https://www.cnblogs.com/wendelhuang/p/7211966.html
Copyright © 2011-2022 走看看