URL编解码

时间:2020-05-10 10:15:01   收藏:0   阅读:52

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!