package t1;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
//URL编码
public class SecUrl {
public static void main(String[] args) throws UnsupportedEncodingException {
String original = "URL 参数";
String encoded = URLEncoder.encode(original, "UTF-8");
System.out.println(encoded);
System.out.println(URLDecoder.decode(encoded, "UTF-8"));
}
}
输出:
URL+%E5%8F%82%E6%95%B0
URL 参数
URL编码不是加密算法,他把英文数字 减号中划线星号点号原样输出,
把中文等其他字符用%的前缀输出,空格以加号或者%20输出。
原文:https://www.cnblogs.com/dengw125792/p/12861574.html