Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
2017-11-13 23:55
931 查看
问题描述
当在.properties的配置文件中有中文时,读取出来的总是乱码。比如我的
application.properties配置文件的内容如下:
server.port=9090 test.msg=你好:Springboot
当在程序中读取
test.msg值时总是会得到乱码,默认是以
ISO-8859-1的字符编码读取,尝试的方法有:
1、添加配置
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
2、设置文件类型
将
application.properites的文件类型修改为
UTF-8的编码类型。
通过以上方法测试获取出来的值还是乱码。
· 解决办法
设置File Encodings的
Transparent native-to-ascii conversion为
true,具体步骤如下:依次点击
File -> Settings -> Editor -> File Encodings
将
Properties Files (*.properties)下的
Default encoding for properties files设置为
UTF-8,将
Transparent native-to-ascii conversion前的勾选上。
代码文档地址:http://www.zslin.com/web/article/detail/12
代码仓库地址:https://github.com/zsl131/spring-boot-test/tree/master/study02
相关文章推荐
- 关于Spring boot中读取属性配置文件出现中文乱码的问题的解决
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- spring boot 配置文件中文乱码问题
- Springboot解决IDEA读取properties配置文件的中文乱码
- spring使用@Value标签读取.properties文件的中文乱码问题的解决
- MySql 5.6 版本 2016-07 修改配置文件解决中文乱码问题
- 用加载字符串配置文件的方式解决cocos2D-x项目中文乱码问题
- Spring Boot配置文件乱码的问题
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- 解决Springboot使用FastJson 返回中文乱码的问题
- spring boot新手教程之使用FastJson解析JSON数据以及解决返回中文乱码问题
- SSH项目web.xml文件的常用配置【struts2的过滤器、spring监听器、解决Hibernate延迟加载问题的过滤器、解决中文乱码的过滤器】
- spring使用@Value标签读取.properties文件的中文乱码问题的解决
- spring使用@Value标签读取*.properties文件的中文乱码问题的解决
- Mysql数据库解决中文乱码问题【不修改my.ini配置文件】
- <util:properties/>加载的配置文件中有中文导致乱码,如何通过分析源码解决问题?
- Springboot使用FastJson后,接口返回中文乱码的问题解决。