You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
858 B
25 lines
858 B
package org.leolo.web.dm.util; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
public class ServletUtil { |
|
public static String getClientIpAddr(HttpServletRequest request) { |
|
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.getHeader("HTTP_CLIENT_IP"); |
|
} |
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
|
ip = request.getHeader("HTTP_X_FORWARDED_FOR"); |
|
} |
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
|
ip = request.getRemoteAddr(); |
|
} |
|
return ip; |
|
} |
|
}
|
|
|