码迷,mamicode.com
首页 > 其他好文 > 详细

properties解决中文乱码

时间:2020-01-10 13:00:29      阅读:99      评论:0      收藏:0      [点我收藏+]

标签:ext   hash   string   getconf   property   eprof   ica   hashmap   ppt   

读取 properties文件,解决中文乱码
        ConfigurableEnvironment environment = context.getEnvironment();
            String env=environment.getActiveProfiles()[0];
            Properties   pro = new Properties();
            Map<String, String> mpro = new HashMap<String, String>();
            String proName ="/application-"+env+".properties";
            InputStreamReader isr=null;
            isr=new InputStreamReader( this.getClass().getResourceAsStream(proName),"UTF-8");
            pro.load(isr);
            Iterator<String> it=pro.stringPropertyNames().iterator();
            shopAppTabs= pro.getProperty("lanhu.appTab.shopAppTab");

使用apollo读取,当前类添加@EnableApolloConfig,读取对应namespace

 Config config = ConfigService.getConfig("RD.int-spring-qpl-shop");
config.getProperty("lanhu.appTab.shopAppTab","")

properties解决中文乱码

标签:ext   hash   string   getconf   property   eprof   ica   hashmap   ppt   

原文地址:https://www.cnblogs.com/li-lun/p/12175455.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!