Home > Operation and Maintenance > Linux Operation and Maintenance > How to solve jsp linux garbled problem

How to solve jsp linux garbled problem

藏色散人
Release: 2021-11-24 10:40:12
Original
2099 people have browsed it

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.

How to solve jsp linux garbled problem

#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
Copy after login

change the original:

LANG="zh_CN.UTF-8"
SUPPORTED="zh_CN.UTF-8:zh_CN:zh"
SYSFONT="latarcyrheb-sun16"
Copy after login

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"
Copy after login

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"); //指定编码
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template