Java中的 url 参数如何删除

当运行项目时,有一个 URL。

http://localhost:8084/blog1_1/title?uname=55%22

从这个 URL 中删除查询字符串,如下所示:

http://localhost:8084/blog1_1/title

 就可使用下面的字符串处理了

String url="http://localhost:8084/blog1_1/title?uname=55%22";
String onlyUrl=url.substring(0,url.lastIndexOf("?")); //this has the URL

猜你喜欢

转载自blog.csdn.net/qq_41954585/article/details/129258196