话不多说,请看实例代码
1
2
3
4
5
6
7
8
9
10
11
|
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(); } System.out.println( "ip:" +ip); |
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持服务器之家!
原文链接:http://www.cnblogs.com/houhaihu/p/6178188.html