<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" errorPage="../error.jsp"%> <% //1、获得指定的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(); } //System.out.println(ip); //设置过滤的IP段"XXX.XXX.XXX.23;XXX.XXX.XXX.1-XXX.XXX.XXX.255;" String filtersIPs="211.160.21.141-211.160.21.145;192.168.2.0-192.168.2.255"; // String [] ips=filtersIPs.split(";"); String tempIp=null; String [] tempIps=null; // boolean isPre=false; if(ips.length>0){ for(int i=0;iend){ int m=begin; begin=end; end=m; } //操作过滤 for(int m=begin;m<=end;m++){ if((preIps+"."+m).equalsIgnoreCase(ip)){ isPre=true; break; } } if(isPre) break; }else { //单独的IP地址-过滤操作 if(ips[i].equalsIgnoreCase(ip)){ isPre=true; break; } } } // if(!isPre){ %>