下面的代码我相信大家可能都会遇到:
window.location.href="/suisitu/suser/user_insert?userCode="+usercode+"&username="+username+"&changeuser="+ChangUser+"&changedate="+ChangDate;
这样传递参数的方式获取比较愚蠢。但是如果不得已为之那怎么解决呢?
解决办法是:
window.location.href=encodeURI(encodeURI("/suisitu/suser/user_insert?userCode="+usercode+"&username="+username+"&changeuser="+ChangUser+"&changedate="+ChangDate));
而在java的页面端则使用:
URLDecoder.decode(username, "utf-8");
这样就可以解决了。