路,要靠自己走。永远不要把希望都寄托在他人身上,关键时候,他人可以推你一把,但不可能完全替代你。学做一只蜗牛吧,即使步履缓慢,也要努力一步一步自己往前爬。心里的痛,总是借助文字来化解。
本文实例讲述了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程序设计有所帮助。
本文javascriptp获取客户端IP地址的方法到此结束。学习是苦根上长出来的甜果。小编再次感谢大家对我们的支持!