获得http://ip:8080的方法

来源:互联网 发布:webshell powershell 编辑:程序博客网 时间:2024/05/18 13:23

要获得地址前半部分,如http://192.168.0.0:8080这个字符串

String path1 = ServletActionContext.getRequest().getRequestURL().toString();

http://192.168.0.0:8080/12319/callRecord/list.do

String path2 = ServletActionContext.getRequest().getRequestURI().toString();

/12319/callRecord/list.do

 

然后将两个string相减

String path3 = path2.replaceAll(path1, "");

此时就获得了地址的前半部分path3

原创粉丝点击