JWSDK中的中文问题

pangpang214 2003-02-19 12:45:40
怎么在JSP页面上显示中文,我显示出的是一堆乱码,我的服务器是JWSDK
...全文
57 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
pangpang214 2003-02-20
  • 打赏
  • 举报
回复
试过了,没用
sgr_kk 2003-02-19
  • 打赏
  • 举报
回复
在开头加上
<%@ page contentType="text/html;charset=gb2312" %>
xmvigour 2003-02-19
  • 打赏
  • 举报
回复
到csdn文档中心去看看java专栏
里面有关于中文开发的一些问题
hou_jg 2003-02-19
  • 打赏
  • 举报
回复
1. 首要条件,在页面头部加上下面语句:
<%@ page contentType="text/html;charset=gb2312" %>

2. 如果涉及到数据的存储和显示,则存储时需要先将页面的数据由GB码转换为Unicode码,显示时再将数据库中的数据由Unicode码转换为GB码,下面给出两个方法,用来相互转换:
//将Unicode码转换为GB码
public static String UnicodeToGB(String pstrIn){
byte[] b;
String strOut = null;
if(pstrIn == null || (pstrIn.trim()).equals(""))
return pstrIn;
try{
b=pstrIn.getBytes("GBK");
strOut=new String(b,"ISO8859_1");
}catch(UnsupportedEncodingException e){}
return strOut;
}

//将GB码转换为Unicode码
public static String GBToUnicode(String pstrIn){
String strOut = null;
if(pstrIn == null || (pstrIn.trim()).equals(""))return pstrIn;
try{
byte[] b = pstrIn.getBytes("ISO8859_1");
strOut = new String(b,"GBK");
}catch(Exception e){

}
return strOut;
}

81,115

社区成员

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

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