Java中获取完整的url

Java中获得完整的URl字符串

1 HttpServletRequest httpRequest=(HttpServletRequest)request;  
2           
3 String strBackUrl = "http://" + request.getServerName() //服务器地址  
4                     + ":"   
5                     + request.getServerPort()           //端口号  
6                     + httpRequest.getContextPath()      //项目名称  
7                     + httpRequest.getServletPath()      //请求页面或其他地址  
8                 + "?" + (httpRequest.getQueryString()); //参数  

 

posted @ 2016-03-01 16:25  魔流剑  阅读(666)  评论(0编辑  收藏  举报