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;
}
取得地址栏完整请求信息
最新推荐文章于 2022-04-26 23:21:03 发布