在上述条件下,问什么在jsp页面下不能显示汉字,我写的汉字都是乱码,在线求助!
try:
下面这个,或许可以帮你解决问题!
<%=new String(rs(yourfield).getBytes,"iso-8859-1")%>
(潇雨寒)
同意!!
<%@ page language="Java" contentType="text/html; charset=GB2312"%>
<%
request.setCharacterEncoding("gb2312");
%>
public String toGb(String uniStr){
String gbStr = "";
if(uniStr == null){
uniStr = "";
}
try{
byte[] tempByte = uniStr.getBytes("ISO8859_1");
gbStr = new String(tempByte,"GB2312");
}catch(UnsupportedEncodingException uef){
}
return gbStr;
}
public String toUni(String gbStr){
String uniStr = "";
if(gbStr == null){
gbStr = "";
}
try{
byte[] tempByte = gbStr.getBytes("GB2312");
uniStr = new String(tempByte,"ISO8859_1");
}catch(UnsupportedEncodingException uef){
}
return uniStr;
}