How to remove the parameters in url Java

不打扰是莪最后的温柔 提交于 2019-12-13 11:05:21

问题


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?


回答1:


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



回答2:


Assuming the url is a java String:

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

should do the trick...



来源:https://stackoverflow.com/questions/29917970/how-to-remove-the-parameters-in-url-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!