日期:2014-05-16  浏览次数:20332 次

js编码中文url
js编码中文url/jsp解码
本来很简单的东西,试了半天总不成,
使用js的函数encodeURI和encodeURIComponent编码url的中文字符串,
jsp取到以后一堆乱码

一番尝试之后,终于得出正确结果:
js:
  
encodeURIComponent(encodeURIComponent("中文"));

jsp:
   
String param = request.getParameter("param");
URLDecoder.decode(param,"UTF-8");


但是也没明白为什么要encodeURIComponent两次才行