美文网首页
URLDecoder: Illegal hex characte

URLDecoder: Illegal hex characte

作者: 红鱼丶 | 来源:发表于2017-12-21 17:07 被阅读0次

Java调用 URLDecoder.decode(str, "UTF-8"); 抛出以上的异常,其主要原因是% 在URL中是特殊字符,需要特殊转义一下,

解决办法:使用%25替换字符串中的%号

String url = url.replaceAll("%(?![0-9a-fA-F]{2})","%25");

url=URLDecoder.decode(url,"UTF-8");

URLDecoder.decode

借鉴:http://blog.csdn.net/afgasdg/article/details/40304817

相关文章

网友评论

      本文标题:URLDecoder: Illegal hex characte

      本文链接:https://www.haomeiwen.com/subject/jviawxtx.html