标签:http java for ar c ad blank return
public static String getIpAddr(HttpServletRequest request) { if (null == request) { return null; } String proxs[] = { "X-Forwarded-For", "Proxy-Client-IP", "WL-Proxy-Client-IP", "HTTP_CLIENT_IP", "HTTP_X_FORWARDED_FOR" }; String ip = null; for (String prox : proxs) { ip = request.getHeader(prox); if (StringUtils.isBlank(ip) || "unknown".equalsIgnoreCase(ip)) { continue; } else { break; } } if (StringUtils.isBlank(ip)) { return request.getRemoteAddr(); } return ip; }
java获取客户端请求ip地址,布布扣,bubuko.com
标签:http java for ar c ad blank return
原文地址:http://my.oschina.net/sunnywu/blog/298017