//获取外网IP
public String getIpAddr(HttpServletRequest request) {
//处理代理访问获取不到真正的ip问题的
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
//获取代理中中的ip
ip = request.getHeader("PRoxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
//获取代理中中的ip
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
//非代理的情况获取ip
ip = request.getRemoteAddr();
}
return ip;
}