How to remove the parameters in url Java

2019-09-24 07:40发布

I have a URL when I run my project.

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

and I want remove the query string from this URL like below:

http://localhost:8084/blog1_1/title

Can you please suggest me how to do this?

2条回答
走好不送
2楼-- · 2019-09-24 07:43
String url="http://localhost:8084/blog1_1/title?uname=55%22";
String onlyUrl=url.substring(0,url.lastIndexOf("?")); //this has the URL
查看更多
混吃等死
3楼-- · 2019-09-24 07:54

Assuming the url is a java String:

String newURL = url.substring(0, url.indexOf("?"));

should do the trick...

查看更多
登录 后发表回答