ajax传参乱码

来源:百度知道 编辑:UC知道 时间:2024/06/08 19:08:45
xmlHttp = CreateXmlHttpRequest();
var url = "GetSelect.jsp";
xmlHttp.open("Post",url,true);//发带参数请求
xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
//xmlHttp.setrequestheader("content-type","application/x-www-form-urlencoded");
xmlHttp.onreadystatechange =panduan;//状态完成改变则显示结果

xmlHttp.send("cvalue="+value);
value传到jsp页面得到的值为乱码请问如何解决

String str1 = request.getParameter("name");
if (str1 != null ) {
byte[] bt1 = str1.getBytes("ISO8859_1");//用ISO8859_1进行编码
String str2 = new String(bt1,"GBK");//用GBK进行解码,构建1个新的字符串
}
else str1 = "";