ajax get 到servlet 解决utf-8中文乱码

<script type="text/javascript">

 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();
   	
   }

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

相关文章

JS原生Ajax操作(XMLHttpRequest) GET请求 POST请求 兼容性问题 利用iframe模拟ajax 实现表单提交的返回...
AJAX 每日更新前端基础,如果觉得不错,点个star吧 &#128515; https://github.com/WindrunnerMax/E...
踩坑Axios提交form表单几种格式 前后端分离的开发前后端, 前端使用的vue,后端的安全模块使用的SpringSe...
很早就听闻ajax的名声,但是却一直不知道怎么用,今天自己捣鼓了一下,竟然会用了,哈哈哈哈。 为了防止...
需要在服务器上进行哈 jquery的ajax方法: // jquery请求 $.ajax({ url: &quot;./server/slider.js...
Ajax函数封装ajax.js // Get / Post // 参数 get post // 是否异步 // 如何处理响应数据 // URL // var...