jsp中:
<%@ page contentType="text/html; charset=GBK"%>
<%request.setCharacterEncoding("GBK");%>
<HEAD><META http-equiv="Content-Type" content="text/html; charset=GBK"></HEAD>
servlet中:
req.setCharacterEncoding("GBK");
如果还不好使,在存入数据库前用下面函数处理字符串
public String switchChinese(String str) {
try{
String temp;
byte[] temp_byte=str.getBytes("ISO8859-1");
temp=new String(temp_byte,"GBK");
return temp;
}
catch(Exception e){
return null;
}
}
<%@ page contentType="text/html; charset=GBK"%>
<%request.setCharacterEncoding("GBK");%>
<HEAD><META http-equiv="Content-Type" content="text/html; charset=GBK"></HEAD>
servlet中:
req.setCharacterEncoding("GBK");
如果还不好使,在存入数据库前用下面函数处理字符串
public String switchChinese(String str) {
try{
String temp;
byte[] temp_byte=str.getBytes("ISO8859-1");
temp=new String(temp_byte,"GBK");
return temp;
}
catch(Exception e){
return null;
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货