public static String getIPAddress(HttpServletRequest request) throws Exception{ |
String ip = request.getHeader( "x-forwarded-for" ); |
if (ip == null || ip.length() == 0 || "unknown" .equalsIgnoreCase(ip)) { |
ip = request.getHeader( "Proxy-Client-IP" ); |
} |
if (ip == null || ip.length() == 0 || "unknown" .equalsIgnoreCase(ip)) { |
ip = request.getHeader( "WL-Proxy-Client-IP" ); |
} |
if (ip == null || ip.length() == 0 || "unknown" .equalsIgnoreCase(ip)) { |
ip = request.getRemoteAddr(); |
} |
return ip.equals( "0:0:0:0:0:0:0:1" )? "127.0.0.1" :ip; |
} |
by: 发表于:2017-07-14 10:10:58 顶(0) | 踩(0) 回复
??
回复评论