Home >Web Front-end >JS Tutorial >The solution to the Chinese garbled value passed in js url_javascript skills
In websphere, url=encodeURI(encodeURI(url)) is used; //Used encodeURI twice and the test was successful. The first conversion was not attempted.
Processing method one.
js program code: url=encodeURI(url); note that it is the entire URL
Server-side code: String linename = new String(request.getParameter("name").getBytes("ISO-8859-1") ,"UTF-8");
Processing method two.
js: var url="name=" name;
url=encodeURI(encodeURI(url)); //Used 2 times encodeURI
window.location = "/inner/line/ line.jsp?" url;
Server-side code:
String linename = request.getParameter(name);
//java: Character decoding
linename = java.net.URLDecoder.decode(linename , "UTF-8");