标签:获取ip ring real head ase servlet cas ignore object
按照我这个代码,如果有代理过的,基本也能获取到IP地址。
public String getRemoteHost(HttpServletRequest request) {
String ip = request.getHeader("x-forwarded-for");
if (ObjectUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("x-real-ip");
}
if (ObjectUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
return ip;
}
标签:获取ip ring real head ase servlet cas ignore object
原文地址:https://www.cnblogs.com/ilii/p/14311511.html