1             String ip = request.getHeader("x-forwarded-for");
 2             if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
 3                 ip = request.getHeader("Proxy-Client-IP");
 4             }
 5             if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
 6                 ip = request.getHeader("WL-Proxy-Client-IP");
 7             }
 8             if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
 9                 ip = request.getRemoteAddr();
10             }
11             System.out.println("ip:"+ip);

 

posted on 2016-12-14 10:18  大柚子哦  阅读(423)  评论(0编辑  收藏  举报