您好,欢迎访问一九零五行业门户网

如何解决jsp linux 乱码问题

jsp linux乱码的解决办法:1、在root用户下修改“lang=zh_cn.gb2312”;2、在处理包含汉字字符串时指定gb2312或者gb2312编码即可。
本文操作环境:linux5.9.8系统、dell g3电脑。
如何解决jsp linux 乱码问题?
linux下的jsp乱码解决方法
我在jsp中用的是gb2312编码
而linux系统默认的是utf-8
所以导致在linux下运行的网站,获取数据库中的中文全是乱码,具体解决:
1.在root用户下
vi /etc/sysconfig/i18n
将原来的:
lang="zh_cn.utf-8"supported="zh_cn.utf-8:zh_cn:zh"sysfont="latarcyrheb-sun16"
改为
# 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.处理包含汉字字符的字符串时要指定gb2312或者gb2312编码
如: 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"); //指定编码
推荐学习:《linux视频教程》
以上就是如何解决jsp linux 乱码问题的详细内容。
其它类似信息

推荐信息