jsp获取客户端IP地址的方法
程序员文章站
2022-05-18 12:38:45
本文实例讲述了jsp获取客户端ip地址的方法。分享给大家供大家参考,具体如下:
public static string getipaddr(httpservle...
本文实例讲述了jsp获取客户端ip地址的方法。分享给大家供大家参考,具体如下:
public static string getipaddr(httpservletrequest request) { 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.getheader("http_client_ip"); } if (ip == null || ip.length() == 0 || "unknown".equalsignorecase(ip)) { ip = request.getheader("http_x_forwarded_for"); } if (ip == null || ip.length() == 0 || "unknown".equalsignorecase(ip)) { ip = request.getremoteaddr(); } return ip; }
希望本文所述对大家jsp程序设计有所帮助。
上一篇: JSP针对表单重复提交的处理方法
下一篇: 鲜牛肉怎么做营养又美味,让人吃了还想吃