这里是一个格式错误的URL http%3A%2F%2Fexample.com%2。
用PHP
var_dump(urldecode("http%3A%2F%2Fexample.com%2")); 我得到了
string(20) "http://example.com%2"但是,当使用Java时
URLDecoder.decode("http%3A%2F%2Fexample.com%2", StandardCharsets.UTF_8.toString()); 我得到了
java.lang.IllegalArgumentException: URLDecoder: Incomplete trailing escape (%) pattern这是一个简单的URL来展示我的例子。如何在Java中尽可能多地解析URL,即使是格式错误的URL?基本上,返回PHP返回的内容。
发布于 2017-03-31 03:12:12
什么是自然网址?我的意思是,在最后,有2%,http%3A%2F%2Fexample.com%2的自然含义是什么?是http://example.com/吗?似乎有个角色在结尾被剥去了。
https://stackoverflow.com/questions/43131678
复制相似问题