Java中获取完整的URL

Java中获得完整的URl字符串

 

[java] view plain copy print ?
  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()); //参数  

你可能感兴趣的:(Java,Web)