String name = java.net.URLEncoder.encode("测试", "UTF-8");
System.out.println(java.net.URLDecoder.decode(name, "UTF-8")); //测试
System.out.println(name); //%E6%B5%8B%E8%AF%95
name = java.net.URLEncoder.encode(name, "UTF-8");
System.out.println(name); //%25E6%25B5%258B%25E8%25AF%2595
name = java.net.URLDecoder.decode(name, "UTF-8");
System.out.println(name); //%E6%B5%8B%E8%AF%95
System.out.println(java.net.URLDecoder.decode(name, "UTF-8")); //测试```
URLEncoder与URLDecoder的编码、解码
最新推荐文章于 2024-05-03 06:51:32 发布
该博客演示了Java中URLEncoder和URLDecoder的使用,通过编码和解码字符串`测试`,展示了URL编码的过程及其在编码后的变化。通过多次编码解码,说明了URL编码的层次性和解码的正确性。
2344

被折叠的 条评论
为什么被折叠?



