Chinese garbled processing of page delivery

Turned around, easy to use
Passing Chinese query garbled problem requires secondary encoding of the parameters to be passed
例如  window.location.href ="/xx.jsp?name="+name+"";
This will be garbled
change to
window.location.href ="/xx.jsp?name="+  encodeURI(encodeURI(name))+"";

Decode in the accepted jsp page or controller
String name = java.net.URLDecoder.decode(request.getParameter("name"), "utf-8");

This will solve the problem of garbled characters when using window.location.href to transmit Chinese

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326492859&siteId=291194637
Recommended