打印IP 来源

<%
  String userAgent = request.getHeader("User-Agent");
  if (userAgent != null && userAgent.indexOf("http") == -1 && userAgent.toLowerCase().indexOf("spider") == -1) {
    String ip = request.getRemoteHost();
    IpUtil ipUtil = new IpUtil();
    String country = ipUtil.getCountry(ip);
    String area = ipUtil.getArea(ip);
    ip = ip + "(" + country + "-" + area + ")";
    System.out.println(ip + "," + request.getRequestURI() + "?" + request.getQueryString()  + ", [" + userAgent + "]" );
  }
%>

原文地址:https://www.cnblogs.com/zhaoding/p/6251468.html