Home > Article > Operation and Maintenance > How to solve jsp linux garbled problem
Jsp Linux garbled solution: 1. Modify "LANG="zh_CN.GB2312"" under the ROOT user; 2. Just specify gb2312 or GB2312 encoding when processing strings containing Chinese characters.
#The operating environment of this article: linux5.9.8 system, Dell G3 computer.
How to solve the jsp linux garbled problem?
Solution to JSP garbled code under Linux
What I use in JSP It is gb2312 encoding
and the default of LINUX system is UTF-8
. Therefore, the Chinese characters in the database obtained by the website running under LINUX are all garbled. The specific solution is:
1. Under ROOT user
vi /etc/sysconfig/i18n
change the original:
LANG="zh_CN.UTF-8" SUPPORTED="zh_CN.UTF-8:zh_CN:zh" SYSFONT="latarcyrheb-sun16"
to
# vi /etc/sysconfig/i18n 修改该文件的内容 # 表示被注释了 #LANG="zh_CN.UTF-8" #SUPPORTED="zh_CN.UTF-8:zh_CN:zh" #SYSFONT="latarcyrheb-sun16" LANG="zh_CN.GB2312" LANGUAGE="zh_CN.GB2312:zh_CN" SUPPORTED="zh_CN.GB2312:zh_CN:zh_CN.UTF-8" SYSFONT="lat0-sun16" SYSFONTACM="8859-15"
2. When processing strings containing Chinese characters, gb2312 or GB2312 encoding must be specified
如: String caption = new String(caption.getBytes("iso-8859-1"), "gb2312");//传递的参数,指定编码 String templateContent = ""; FileInputStream fileinputstream = new FileInputStream(filePath); // 读取模板文件 int lenght = fileinputstream.available(); byte bytes[] = new byte[lenght]; fileinputstream.read(bytes); fileinputstream.close(); templateContent = new String(bytes,"GB2312"); //指定编码
Recommended study: "linux video tutorial"
The above is the detailed content of How to solve jsp linux garbled problem. For more information, please follow other related articles on the PHP Chinese website!