如何得到项目的地址,如:http://localhost:8080/HR

 

方法一:

String url = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";

方法二:

String projectUrl = request.getRequestURL().toString();
   projectUrl = projectUrl.substring(0, projectUrl.lastIndexOf("/"));

转载于:https://www.cnblogs.com/sp2012/archive/2011/12/24/2465698.html

你可能感兴趣的:(如何得到项目的地址,如:http://localhost:8080/HR)