js中對中文進行編碼:(不對ASCII 字母和數字進行編碼)
window.document.location.href = "${ctxPath}/pc/selectDTByXinFang/html?subWayName="+encodeURI(encodeURI(subWayName))+"&dtId=" + dtId;
//有時只需要編碼一次即可(具體原因沒有細究)
window.document.location.href = "${ctxPath}/pc/selectDTByXinFang/html?subWayName="+encodeURI(subWayName)+"&dtId=" + dtId;
在action中獲取時需要通過URLDecoder.decode(name, "UTF-8");方式進行解碼即可.
//中文解碼
try {
stationName = URLDecoder.decode(stationName, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
------------------------------------------------------------------------------------
js中對中文進行編碼:(對ASCII 字母和數字進行編碼)
window.document.location.href = "${ctxPath}/pc/selectDTByXinFang/html?subWayName="+encodeURIComponent(encodeURIComponent(subWayName))+"&dtId=" + dtId;
//中文解碼
try {
blockName = new String(blockName.getBytes("ISO-8859-1"), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}