【IntelliJ IDEA】从资源文件读取出来就中文乱码的解决方法

在application.properties资源文件中设置两个自定义的属性以及属性值:

com.sxd.name = "德玛西亚"
com.sxd.want = "王者荣耀"

 

然后获取资源文件中定义的属性值出现乱码。

 

解决方法:

在资源文件中添加如下:

banner.charset=UTF-8
server.tomcat.uri-encoding=UTF-8
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
spring.messages.encoding=UTF-8

 

 

posted @ 2017-10-11 15:47  Angel挤一挤  阅读(3068)  评论(0)    收藏  举报