取得地址栏完整请求信息

public static String getCompleteURL(HttpServletRequest request) {   
    return new StringBuilder(getCurrentHttpURL(request))   
        .append(request.getServletPath()).append("?")   
            .append(request.getQueryString()).toString();   
}   
  
/**  
 * 取得当前http地址  
 * @param request  
 * @return  
 * Date: 2008-12-1 下午02:59:03  
 */  
public static String getCurrentHttpURL(HttpServletRequest request){   
       
    StringBuilder urlBuilder = new StringBuilder();   
    urlBuilder.append(request.getScheme()).append("://");   
    urlBuilder.append(request.getServerName());   
    urlBuilder.append(request.getHeader("host")).append(":");   
    urlBuilder.append(request.getServerPort());   
    urlBuilder.append(request.getContextPath()).append("/");   
       
    String httpAddr = urlBuilder.toString();   
    urlBuilder = null;   
    return httpAddr;   
}  

你可能感兴趣的:(请求)