HoneyMoose
  • 首页
  • Java
  • Jersey
  • Jira
  • Confluence
  • U.S.
    • Real Estate
    • U.S. Travel
    • H1B
  • 项目和网站
    • CWIKI.US
    • OSSEZ 社区
    • WIKI.OSSEZ.COM
    • BUG.OSSEZ.COM
    • RSS.OSSEZ.COM
BLOG.OSSEZ.COM
A responsive blog theme focused om user reading experience
  1. Home
  2. Computer Science
  3. This article

Spring Boot API 中文字符乱码

2020年12月21日 43Browse 0Like 0Comments

Spring Boot 在运行 API 的时候如果返回数据库的时候提示中文是乱码。

但是针对不同的浏览器,返回的结果是不一样的。

在 Application.yml 中 添加下面的配置:

server:
  servlet:
    encoding:
      force: true
      charset: UTF-8
      enabled: true

 

chinese-utf8-02

 

然后重新启动服务器后,我们所有的访问都会使用 UTF-8 编码。

这样以避免字符集错误。

 

chinese-utf8-01

 

需要注意的是,不同的浏览器对字符集的编码是不一样的,最好都测一下。

针对手机平台也是不一样的。

https://www.ossez.com/t/spring-boot-api/768

Tags: None
Last updated:2020年12月21日

Kratos

stay absorbed stay excellent

Like
< Previous
Next >

Comments

Cancel reply

Newest Hotspots Random
Newest Hotspots Random
Discourse 主题和回复的日期如何查看 Discourse 如何查看主题的查看数量 Confluence 删除的页面会完全删除吗 Confluence 7 删除页面和子页面 DITA 已死 Java 线程暂停的简单代码
AWS S3 使用 travis 编译的时候提示错误 Aws::S3::Errors::PermanentRedirectTravis 编译使用 JDK 的版本GPG 使用 Maven 签名后发送到中央仓库提示 Upload your public key and try the operationPackage 打包上传到中央仓库的时候提示 SCM URL missingMaven Package 如何使用 GPG 签名Node Sass does not 支持的版本错误
Discourse 数据分发 Confluence 6 移动浏览搜索内容和人 Confluence 6 LDAP 用户结构设置 Confluence 6 为站点启用匿名用户访问 电脑软件(例如 Adobe、Autodesk)为什么那么容易被破解 Angular 文档中链接的修改路径
Categories
  • Akka
  • Algorithm(算法)
  • AMQP
  • Angular
  • CI
  • Compile And CI
  • Computer Science
  • Confluence
  • DataBase
  • Gradle
  • H1B
  • Hibernate
  • IDE
  • Java
  • Jersey
  • Jira
  • MariaDB
  • PrestaShop
  • Real Estate
  • Spring
  • Spring Batch
  • U.S.
  • U.S. Travel
  • 我的小厨

COPYRIGHT © 2020 HoneyMoose. ALL RIGHTS RESERVED.

THEME CWIKIUS.CN MADE BY VTROIS