首页 > 其他 > 详细

properties解决中文乱码

时间:2020-01-10 13:43:57      阅读:229      评论:0      收藏:0      [点我收藏+]
读取 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解决中文乱码

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!