zoukankan      html  css  js  c++  java
  • 从HTTP请求中获取客户IP地址

     /**
         * 从HTTP请求中获取客户IP地址
         *
         * @param request http请求
         * @return 客户IP地址
         */
        public static String getIPAddress( 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;
        }

  • 相关阅读:
    deb app install under terminal
    修改代理
    virtualenv install &usage
    what a pietty
    晚上想睡觉不要喝可乐
    ubuntu server 调教
    修改代理
    修改网关为静态IP
    infobright install tips
    i like fujishu laptop more than mac
  • 原文地址:https://www.cnblogs.com/wangkeai/p/4120904.html
Copyright © 2011-2022 走看看