0514-86177077
9:00-17:00(工作日)
本文實例講述了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程序設(shè)計有所幫助。
標(biāo)簽:開封 烏蘭察布 銅川 吉林 白銀 臨汾 山南 自貢
上一篇:JSP針對表單重復(fù)提交的處理方法
下一篇:純jsp實現(xiàn)的倒計時動態(tài)顯示效果完整代碼
Copyright ? 1999-2012 誠信 合法 規(guī)范的巨人網(wǎng)絡(luò)通訊始建于2005年
蘇ICP備15040257號-8