当前位置:网站首页>一次性彻底解决 Web 工程中文乱码问题
一次性彻底解决 Web 工程中文乱码问题
2022-06-27 13:12:00 【Spring-_-Bear】
一、IDEA 控制台乱码
IDEA 中设置文件编码为 UTF-8
修改 IDEA 安装目录 bin 下的
idea.exe.vmoptions
和idea64.exe.vmoptions
,行尾追加-Dfile.encoding=UTF-8
IDEA 设置控制台打印使用 UTF-8 编码
二、请求数据乱码
IDEA 中修改 Tomcat 使用
-Dfile.encoding=UTF-8
修改 Tomcat 安装目录 conf 下的
server.xml
,在<Connector/>
标签中添加URIEndcong="UTF-8"
解决 GET 请求乱码修改 Tomcat 安装目录 bin 下
catalina.bat
,在如下位置添加-Dfile.encoding=UTF-8
(-Dfile 前只能有一个空格)HTML 页面中引入 JavaScript 文件时使用 UTF-8 编码
<script type="text/javascript" charset="UTF-8" th:src="@{/static/js/login.js}"></script>
清除浏览器缓存,重启 Tomcat
三、部署 Linux 乱码
pom.xml
中设置 Maven 项目打包时使用 UTF-8 编码,避免生成的字节码文件不是 UTF-8 编码部署到远程服务器后再次乱码<properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> <spring.version>5.3.1</spring.version> <!-- Maven 打包编码指定为 UTF-8,避免工程部署到远程服务器后乱码 --> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <!-- Maven 打包时跳过测试 --> <maven.test.skip>true</maven.test.skip> </properties>
边栏推荐
猜你喜欢
[medical segmentation] unet3+
Cool in summer
硬件开发笔记(七): 硬件开发基本流程,制作一个USB转RS232的模块(六):创建0603封装并关联原理图元器件
After 2 years of outsourcing, I finally landed! Record my ByteDance 3 rounds of interviews, hope to help you!
A pang's operation record
How to download pictures with hyperlinks
【周赛复盘】LeetCode第81场双周赛
OpenFeign服务接口调用
Cesium实现卫星在轨绕行
昨天访问量破记录
随机推荐
How to download pictures with hyperlinks
阿胖的操作记录
[acwing] explanation of the 57th weekly competition
外包2年的我终于上岸了!记录我的字节跳动3轮面试,希望帮助到大家!
Yuweng information, a well-known information security manufacturer, joined the dragon lizard community to build an open source ecosystem
抖音实战~公开/私密短视频互转
How to split microservices
Istio微服务治理网格流量管理核心资源控制器详解
[weekly replay] the 81st biweekly match of leetcode
使用bitnamiredis-sentinel部署Redis 哨兵模式
云原生(三十) | Kubernetes篇之应用商店-Helm
mysql 锁机制与四种隔离级别
Pycharm in Chinese
printf不定长参数原理
同花顺能开户炒股吗?安全吗?
[dynamic programming] - Knapsack Problem
crane:字典项与关联数据处理的新思路
Local visualization tool connects to redis of Alibaba cloud CentOS server
Does Xinhua San still have to rely on ICT to realize its 100 billion enterprise dream?
Deeply convinced plan X - system foundation summary