JSP request获得完整路径

方法一:
request.getHeader("Referer") :  获得当前的URL详细地址 如:http://www.sina.com:80/a.php?sa=123


方法二:
<% 
  String   path   =   request.getContextPath(); 
  String   basePath   =   request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 
  out.println(basePath); 
  %> 
获当前当的URL地址  如:http://www.sina.com/WEB-ROOT/

猜你喜欢

转载自matieli.iteye.com/blog/1310284
今日推荐