public String getIpAddr() {
HttpServletRequest request= this.getRequest();
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; }
java获取客户端IP地址
最新推荐文章于 2023-03-21 10:46:17 发布