escape、 unescape()

已编码的 string 的副本。其中某些字符被替换成了十六进制的转义序列。

该方法不会对 ASCII 字母和数字进行编码,也不会对下面这些 ASCII 标点符号进行编码: * @ - _ + . / 。其他所有的字符都会被转义序列替换。


建议使用 decodeURI() 和 decodeURIComponent() 替代它。


======后台解码=====

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

public class EncoderURI {
public static void main(String[] args) {
try {
/****
* encodeURI(encodeURI("中文"))
* "%25E4%25B8%25AD%25E6%2596%2587"
*/

String name="%25E4%25B8%25AD%25E6%2596%2587";
name = URLDecoder.decode("%E4%B8%AD%E6%96%87", "UTF-8");
System.err.println("解密的后的请求参数===="+name);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}