• 获取客户端ip


    public String getRemortIP(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.getHeader("HTTP_CLIENT_IP");
            }
            if ((ip == null) || (ip.length() == 0) || "unknown".equalsIgnoreCase(ip)) {
                ip = request.getHeader("HTTP_X_FORWARDED_FOR");
            }
            if ((ip == null) || (ip.length() == 0) || "unknown".equalsIgnoreCase(ip)) {
                ip = request.getRemoteAddr();
            }
            return ip;
        }

    public String getRemortIP(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.getHeader("HTTP_CLIENT_IP");

            }

            if ((ip == null) || (ip.length() == 0) || "unknown".equalsIgnoreCase(ip)) {

                ip = request.getHeader("HTTP_X_FORWARDED_FOR");

            }

            if ((ip == null) || (ip.length() == 0) || "unknown".equalsIgnoreCase(ip)) {

                ip = request.getRemoteAddr();

            }

            returnip;

        }

  • 相关阅读:
    定时器准确定时八位时钟
    数码管八位显示时钟
    串口通讯
    定时器/计数器0(定时器)
    定时器/计数器0之计数器
    定时器/计数器0(计数器)
    外部中断0
    LCD带字符液晶显示I LOVE YOU
    Altium Designer Summer 09换成中文步骤
    BAT小米奇虎美团迅雷携程等等各大企业校招,笔试面试题。
  • 原文地址:https://www.cnblogs.com/tianxuwei/p/10478983.html
Copyright © 2020-2023  润新知