解决javascript向后台传输汉字乱码

来源:互联网 发布:wp 利用 知乎 编辑:程序博客网 时间:2024/05/18 19:43
--编码
var row=btn.parentElement.parentNode;
var name=document.getElementById("name"+(row.rowIndex-1)).value;
var pwd=document.getElementById("pwd"+(row.rowIndex-1)).value;
var sno=document.getElementById("sno"+(row.rowIndex-1)).value;
tbody1.rows[row.rowIndex-1].cells[0].innerHTML=name;
tbody1.rows[row.rowIndex-1].cells[1].innerHTML=pwd;
tbody1.rows[row.rowIndex-1].cells[2].innerHTML=sno;
tbody1.rows[row.rowIndex-1].cells[3].innerHTML="<input type='button' value='删除'  onclick='confirmDel("+id+")'><input type='button' value='编辑' onclick='alterData(this)'>"
window.location.href="/system1.0/AlterStuUser?id="+id+"&username="+encodeURI(encodeURI(name))+"&password="+pwd+"&sno="+sno+"";


--解码
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
String username=URLDecoder.decode(request.getParameter("username"), "utf-8");
阅读全文
0 0