springboot配置文件乱码
时间: 2023-08-17 14:13:53 浏览: 70
回答: 当使用Spring Boot开发时,理论上是不会出现乱码的,因为Spring Boot默认编码为UTF-8。但是当客户端编码和服务器编码格式不一致时,就会导致乱码。解决这个问题有几种方法。首先,可以和客户端约定请求编码格式,强制约定为UTF-8。\[1\]其次,可以修改Spring Boot的配置文件,增加如下配置来设置编码格式为UTF-8:spring.http.encoding.force=true、spring.http.encoding.charset=UTF-8、spring.http.encoding.enabled=true、server.tomcat.uri-encoding=UTF-8。\[2\]另外,也可以在Configuration类中创建一个自定义的CharacterEncodingFilter来设置编码格式为UTF-8。\[3\]此外,在RequestMapping上添加produces属性,指定返回的数据类型为application/json;charset=utf-8,可以防止中文乱码。\[3\]如果还是出现乱码,可能是读取properties文件时出现了错误。
#### 引用[.reference_title]
- *1* *2* [SpringBoot乱码问题解决](https://blog.csdn.net/qw463800202/article/details/103158653)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [解决SpringBoot返回中文乱码问题方法汇总](https://blog.csdn.net/m0_59278919/article/details/127340225)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)