In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Question:
Recently, there is data garbled when deploying the project. After checking that the project uses the UTF-8 encoding format, so is the data, but the garbled code is passed to the other party after calling the API.
Because it is deployed in Windows environment, Windows encodes GBK by default, which leads to the problem of inconsistent jvm runtime coding, and it is easy to modify.
Solution:
If you use UTF-8 encoding in Linux environment, you don't have to modify it, because Linux defaults to UTF-8
The war package is deployed on Tomcat
Modify jvm coding
Linux environment
Configure in catalina.sh
JAVA_OPTS= "$JAVA_OPTS-Dfile.encoding=utf-8"
Because the default encoding format in the Windows environment is GBK, you need to modify the Tomcat runtime encoding format.
Windows environment
Configure in catalina.bat
Set JAVA_OPTS=%JAVA_OPTS%-Dfile.encoding=UTF-8
For jar package deployment, you only need to add the jvm parameter to the startup command.
Jar package deployment
Start command to add jvm parameter
Java-Dfile.encoding=UTF-8-jar xxx.jar
Summary
The above is the editor to introduce to you to modify the Tomcat runtime jvm coding problems, I hope to help you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.