Apache+Jsver+Servlet无法显示汉字?

freerabbit 2000-03-31 05:31:00
加精
I have installed Apache/1.3.6+Jserv/1.0
and add a line into HelloWorld.java
" out.println("中文测试"); "
But the result is ????
...全文
350 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zzhcom 2000-10-20
  • 打赏
  • 举报
回复
在jsp文件头上加上
<%@ page contentType="text/html;charset=gb2312" %>
JeasonZhao 2000-09-13
  • 打赏
  • 举报
回复
试试看将得到的字符串字符集转换
public static String unicodeToGB(String strIn){
byte[] b;
String strOut = null;
if(strIn == null || (strIn.trim()).equals(""))
return strIn;
try{
b = strIn.getBytes("GBK");
strOut = new String(b,"ISO8859_1");
}catch(UnsupportedEncodingException e){}
return strOut;
}

public static String GBToUnicode(String strIn){
String strOut = null;
if(strIn == null || (strIn.trim()).equals(""))return strIn;
try{
byte[] b = strIn.getBytes("ISO8859_1");
strOut = new String(b,"GBK");
}catch(Exception e){}
return strOut;
}
ejian 2000-07-13
  • 打赏
  • 举报
回复
将 out 定义为:PrintWriter


如:PrintWriter out = res.getWriter();
ahfei 2000-04-03
  • 打赏
  • 举报
回复
你是用什么编译的?如果是jb,改变project->compiler->encoding 为ISO8859_1,
如果直接用jdk,编译是加入参数-encoding ISO8859_1.

如果你不明白的话,就把你的机器区域设置为usa,编译.
土豆 2000-04-01
  • 打赏
  • 举报
回复

81,090

社区成员

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

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