1. 程式人生 > >JS中用encodeURIComponent編碼,後臺JAVA怎麼解碼

JS中用encodeURIComponent編碼,後臺JAVA怎麼解碼

JS中用encodeURIComponent編碼兩次

var p = {};
p.Map = [{f : 'customNo', t : '客戶編號'},{f : 'customName', t : '客戶名稱'}];
var param = JSON.stringify(p);
var url = "http://localhost:8080?data=" + encodeURIComponent(encodeURIComponent(param))
window.open(ulr); 

JAVA中解碼

String data = request.getParameter("data");

data = java.net.URLDecoder.decode(data, "UTF-8");