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

时间:2023-03-09 15:05:17
【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

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

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

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