获取客户端IP地址

public static String getRemoteAddr(HttpServletRequest request) { String remoteAddr = request.getHeader("X-Real-IP"); if (!isBlank(remoteAddr)) remoteAddr = request.getHeader("X-Forwarded-For"); else if (!isBlank(remoteAddr)) remoteAddr = request.getHeader("Proxy-Client-IP"); else if (!isBlank(remoteAddr)) remoteAddr = request.getHeader("WL-Proxy-Client-IP"); return remoteAddr == null ? request.getRemoteAddr() : remoteAddr; }

    推荐阅读