2

IDEA中配置tomcat8.5中文乱码问题

 1 year ago
source link: https://blog.51cto.com/u_15856116/5813291
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

IDEA中配置tomcat8.5中文乱码问题

精选 原创

旷野历程 2022-11-01 12:13:37 博主文章分类:other ©著作权

文章标签 乱码 tomcat ide 编码格式 .net 文章分类 其它 系统/运维 阅读数169

分享知识  传递快乐

项目文件为GBK编码格式,但项目中文件定义的却是UTF-8格式,数据库连接也是UTF-8。

IDEA修改项目编码为UTF-8编码格式,JAVA文件中的中文乱码、控制台日志乱码(tomcat编码格式为默认UTF-8编码)、页面展示部分中文也乱码。

经多方面排查,最后终于解决乱码问题,特此记录一下操作过程:

第一步:设置项目编码为GBK

IDEA中配置tomcat8.5中文乱码问题_ide

设置 Project encodeing:GBK,与项目编码保持一致。

第二步:设置Tomcat编码格式

VM options:-Dfile.encoding=UTF-8
#
JAVA_OPTS:-Dfile.encoding=UTF-8
IDEA中配置tomcat8.5中文乱码问题_tomcat_02
IDEA中配置tomcat8.5中文乱码问题_.net_03

第三步:修改IDEA的 idea.exe.vmoptions 和 idea64.exe.vmoptions 文件

在IDEA的 idea.exe.vmoptions 和 idea64.exe.vmoptions 文件中增加 -Dfile.encoding=UTF-8,保存重启

最后乱码问题解决了

—————————
相互学习,共同进步
如有不足请留言指正

  • 收藏
  • 评论
  • 分享
  • 举报

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK