我的JSP不支持中文 ?

zrlai 2000-09-12 11:35:00
环境: window98 + JRun2.3.3
请教大虾,谢谢!
...全文
241 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
javaduke 2000-12-22
  • 打赏
  • 举报
回复
关键是根据不同的开发平台采用不同的方法!
www.dukejava.com
hwjatom 2000-12-19
  • 打赏
  • 举报
回复
还有一种
ServletOutputStream out=res.getOutputStream();
DataOutputStream uniout = new DataOutputStream(out)
然后向uniout写出文本
blueseashore 2000-11-22
  • 打赏
  • 举报
回复
这几种方法都可以!!!
yym 2000-09-16
  • 打赏
  • 举报
回复
语法写错了,应为<@ page contentType="text/html; charset=gb2312">

yym 2000-09-16
  • 打赏
  • 举报
回复
错了错了,人家是问JSP,而不是Servlet,
只要在 jsp 文件中使用 <@ page contentType="text/html; charset=gb2312">
就OK了
oldgun 2000-09-13
  • 打赏
  • 举报
回复
private String gbToUnicode(String src) {
char[] c = src.toCharArray();
int n = c.length;
byte[] b = new byte[n];
for (int i = 0; i < n; i++)
b[i] = (byte) c[i];
return new String(b);
}


private String unicodeToGb(String o) {
byte[] b = o.getBytes();
int n = b.length;
char[] c = new char[n];
for (int i = 0; i < n; i++)
c[i] = (char) ((short) b[i] & 0xff);
return new String(c);
}

用这两个方法转换一下
p9 2000-09-12
  • 打赏
  • 举报
回复
ServletOutputStream out=res.getOutputStream();
改为:
PrintWrite out=res.getWrite();

res.setContentType("text/html");
改为
res.setContentType("text/html;charset=GB2312");

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧