当前位置:网站首页>一次性彻底解决 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>
边栏推荐
- #yyds干货盘点# 解决剑指offer:剪绳子(进阶版)
- OpenFeign服务接口调用
- [tcaplusdb knowledge base] Introduction to tcaplusdb tcapulogmgr tool (I)
- JSON. Stringify usage
- Vs debugging skills
- Hardware development notes (VII): basic process of hardware development, making a USB to RS232 module (VI): creating 0603 package and associating principle graphic devices
- 浅谈软件研发的复杂性与效能提升之道
- Privacy computing fat offline prediction
- Stack calculation (whether the order of entering and leaving the stack is legal) - Code
- 【第27天】给定一个整数 n ,打印出1到n的全排列 | 全排列模板
猜你喜欢

Yuweng information, a well-known information security manufacturer, joined the dragon lizard community to build an open source ecosystem

Realization of hospital medical record management system based on JSP

基于STM32设计的蓝牙健康管理设备

PLM还能怎么用?

深入理解位运算

昨天访问量破记录

Journal quotidien des questions (6)

ZABBIX supports nail alarm

Hardware development notes (VII): basic process of hardware development, making a USB to RS232 module (VI): creating 0603 package and associating principle graphic devices

Crane: a new way of dealing with dictionary items and associated data
随机推荐
gcc编译动态库和静态库
Differences in perspectives of thinking
How to use 200 lines of code to implement Scala's Object Converter
Firewall foundation Huawei H3C firewall web page login
AGCO AI frontier promotion (6.27)
VS调试技巧
Airbnb double disk microservice
How to set postman to Chinese? (Chinese)
Bluetooth health management device based on stm32
Make learning pointer easier (2)
Hue new account error reporting solution
每日刷题记录 (六)
昨天访问量破记录
Different habits
GCC compiling dynamic and static libraries
zabbix支持钉钉报警
jvm 参数设置与分析
清楚的自我定位
Prometheus 2.26.0 new features
Crane: a new way of dealing with dictionary items and associated data