今天发现一个问题
有一个页面,通过JS的location.url跳转
中间传了几个条件参数,但这个参数是中文的时候,就出现了乱码问题
网上搜所,解决方案如下
1.页面编码
- //导出
- function exportExcel(){
- var projectName_e = document.getElementById("pname").value;
- var unitName = document.getElementById("unitName").value;
- var projectState = document.getElementById("projectState").value;
- var lyear = document.getElementById("lxYear").value;
- var str = "projectName_e="+encodeURIComponent(projectName_e)+"&unitName="+encodeURIComponent(unitName)+"&lyear="+lyear
- window.location="<%=basePath%>/mproject/project_getAllProjectList.action?"+str+"&flag=1&projectType=${projectType}";
- }
2.Action解码
- String word="页面传过来的中文参数"
- String temp = new String(keyword.getBytes("ISO-8859-1"),"utf-8");
- keyword = URLDecoder.decode(temp, "utf-8");