不是所有地方都会用Ajax  当你使用window.location.href 来传中文参数的时候 如何避免乱码问题

 

js 是这样写的    下面代码中  方式 封装编码  参数 username 

var url = "../classsetting/jumpJsp.do" + (classids.length>0 ? ("?classids="+classids + "&un+userid+
"&username=" +encodeURI(encodeURI(username))) : "");
window.location.href=url

 

在后台 我们需要解码  代码如下  例如依旧 拿去 username 这个参数

java.net.URLDecoder.decode(username, "utf-8");

这样就能够避免中文乱码问题

 

相关文章:

  • 2022-12-23
  • 2021-11-23
  • 2022-02-11
  • 2021-07-27
  • 2021-06-10
  • 2022-01-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-03-01
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
  • 2021-12-11
  • 2021-08-11
相关资源
相似解决方案