日期:2014-05-16  浏览次数:20412 次

求教,怎么获得当前浏览器框里的ip地址呢
求教,怎么获得当前浏览器框里的ip地址呢

------解决方案--------------------
哦,看错题意了
------解决方案--------------------
说具体点
------解决方案--------------------
获得客户端真实IP地址的例一:
  public String getRemortIP(HttpServletRequest request) {
  if (request.getHeader("x-forwarded-for") == null) {
  return request.getRemoteAddr();
  }
  return request.getHeader("x-forwarded-for");
  }
  获得客户端真实IP地址的例二:
  public 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.getRemoteAddr();
  }
  return ip;
  }
------解决方案--------------------
探讨

获得客户端真实IP地址的例一:
public String getRemortIP(HttpServletRequest request) {
if (request.getHeader("x-forwarded-for") == null) {
return request.getRemoteAddr();
}
return request.getHeader("x-forwa……