ajax的get中文乱码问题,ajax get 到servlet 解决utf-8中文乱码

function save(){

var xmlhttp;

if (window.XMLHttpRequest)

{// code for IE7+,Firefox,Chrome,Opera,Safari

xmlhttp=new XMLHttpRequest();

}

else

{// code for IE6,IE5

xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

}

alert("ppp");

var deviceImgDate = document.getElementById("deviceImgDate").value;

var deviceCheck1 = document.getElementById("deviceCheck1").value;

var deviceCheck2 = document.getElementById("deviceCheck2").value;

var deviceCheck3 = document.getElementById("deviceCheck3").value;

var deviceCheck4 = document.getElementById("deviceCheck4").value;

var deviceCheck5 = document.getElementById("deviceCheck5").value;

var deviceCheck6 = document.getElementById("deviceCheck6").value;

var deviceCheck7 = document.getElementById("deviceCheck7").value;

var deviceCheck8 = document.getElementById("deviceCheck8").value;

var deviceCheck9 = document.getElementById("deviceCheck9").value;

var deviceCheck10 = document.getElementById("deviceCheck10").value;

var deviceCheck11 = document.getElementById("deviceCheck11").value;

var deviceCheck12 = document.getElementById("deviceCheck12").value;

var deviceCheck13 = document.getElementById("deviceCheck13").value;

var deviceCheck14 = document.getElementById("deviceCheck14").value;

var deviceCheck15 = document.getElementById("deviceCheck15").value;

var deviceScope = document.getElementById("deviceScope").value;

var url="deiviceImgCheckServlet?deviceImgDate="+encodeURI(deviceImgDate)+"&deviceCheck1="+encodeURI(deviceCheck1)

+"&deviceCheck2="+encodeURI(deviceCheck2)+"&deviceCheck3="+encodeURI(deviceCheck3)+"&deviceCheck4="+encodeURI(deviceCheck4)

+"&deviceCheck5="+encodeURI(deviceCheck5)+"&deviceCheck6="+encodeURI(deviceCheck6)+"&deviceCheck7="+encodeURI(deviceCheck7)

+"&deviceCheck8="+encodeURI(deviceCheck8)+"&deviceCheck9="+encodeURI(deviceCheck9)+"&deviceCheck10="+encodeURI(deviceCheck10)

+"&deviceCheck11="+encodeURI(deviceCheck11)+"&deviceCheck12="+encodeURI(deviceCheck12)+"&deviceCheck13="+encodeURI(deviceCheck13)

+"&deviceCheck14="+encodeURI(deviceCheck14)+"&deviceCheck15="+encodeURI(deviceCheck15)+"&deviceScope="+encodeURI(deviceScope);

alert(url);

xmlhttp.open("post",url,true);

xmlhttp.send(null);

alert("aaa");

window.location.reload();

}

jsp: servlet/MsgServlet?userName=encodeURI('张三'),用encodeURI方法处理的都是UTF-8的 servlet: URLDecoder.decode(request.getParameter("userName").getString(),"UTF-8"));

总结

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值