如何得到项目的地址,如: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("/"));

posted on 2011-12-24 11:17  sp2012  阅读(505)  评论(0编辑  收藏  举报