前台, 用encodeURI
$.getJSON("/portal/edu/findEduList?keyword="+encodeURI(keyword,"utf-8")+"&rn="+Math.random(),function(data){
后台用decode解析
try {
URLDecoder.decode(keyword,"utf-8");
} catch (Exception e) {
e.printStackTrace();
}
前台, 用encodeURI
$.getJSON("/portal/edu/findEduList?keyword="+encodeURI(keyword,"utf-8")+"&rn="+Math.random(),function(data){
后台用decode解析
try {
URLDecoder.decode(keyword,"utf-8");
} catch (Exception e) {
e.printStackTrace();
}
转载于:https://www.cnblogs.com/wujixing/p/5855223.html