Jsp获取客户端IP地址(我看不懂代码,求注释)
<%
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.getRemoteAddr();
%>
<input type = "hidden" name="ip"
value="<%= request.getRemoteAddr()%>" id="macip"/>
<br/>
<%
}
%>
虽然有代码,但没有注释,我看不懂哦。
高手请指点指点。小弟先谢谢啦……