jeesite.properties属性文件为utf-8格式时的加载修改

在idea内修改jeesite(https://github.com/thinkgem/jeesite)时,首要的一个地方就是修改jeesite.properties。

通常的,我们会在idea内将properties文件的编码设置为UTF-8,因此,你在修改jeesite.properties后,就会出现一些乱码的问题:

比如,jeesite登录页面的网站标题是在jeesite.properties文件内的productName属性进行设置的,但是修改运行后此标题将会变成乱码。

本文的解决方法是:在jeesite项目内PropertiesLoader类的加载属性方法loadProperties加载属性文件时,为输入流指定编码,如下:

修改前:

// com.thinkgem.jeesite.common.utils.PropertiesLoader类

 

/**
    * 载入多个文件, 文件路径使用Spring Resource格式.
    */
  
private Properties loadProperties(String... resourcesPaths) {
      // 省略……
            Resource resource = resourceLoader.getResource(location);
            is = resource.getInputStream();
            props.load(is);
         } catch (IOException ex) {
      // 省略……

      return props;
   }

 

 

修改后(见红色部分):

// com.thinkgem.jeesite.common.utils.PropertiesLoader类

 

/**
    * 载入多个文件, 文件路径使用Spring Resource格式.
    */
  
private Properties loadProperties(String... resourcesPaths) {
      // 省略……
            Resource resource = resourceLoader.getResource(location);
            is = resource.getInputStream();
            // props.load(is);

            props.load(new InputStreamReader(is, "UTF-8"));
         } catch (IOException ex) {
      // 省略……

      return props;
   }

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值