Java中获取完整的URL

来源:互联网 发布:mysql 存储过程 编辑:程序博客网 时间:2024/05/16 15:08

Java中获得完整的URl字符串

 

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

0 0