java中使用encode转码和解码
String str = URLEncoder.encode("中国","utf-8");
System.out.println(str);
//解码
String str1=URLDecoder.decode(str, "UTF-8");
System.out.println(str1);
打印结果
%E4%B8%AD%E5%9B%BD
中国
js中使用encode转码和解码
转码encodeURIComponent,还可以使用encodeURI来编码
解码除了decodeURIComponent,还可以使用decodeURI来解码