goja-web/src/main/java/goja/mvc/kits/Requests.java
public static String remoteIP(HttpServletRequest request) {
        String ipAddress;
        ipAddress = request.getHeader("x-forwarded-for");
        if ((ipAddress == null) || (ipAddress.length() == 0)
                || ("unknown".equalsIgnoreCase(ipAddress))) {
            ipAddress = request.getHeader("Proxy-Client-IP");
        }
        if ((ipAddress == null) || (ipAddress.length() == 0)
                || ("unknown".equalsIgnoreCase(ipAddress))) {
            ipAddress = request.getHeader("WL-Proxy-Client-IP");
        }
        if ((ipAddress == null) || (ipAddress.length() == 0)
                || ("unknown".equalsIgnoreCase(ipAddress))) {
            ipAddress = request.getRemoteAddr();
            if (ipAddress.equals("127.0.0.1")) {
                InetAddress inet;
                try {
                    inet = InetAddress.getLocalHost();
                    ipAddress = inet.getHostAddress();
                } catch (UnknownHostException e) {
                    e.printStackTrace();
                }
            }
        }
        if ((ipAddress != null) && (ipAddress.length() > 15)) {
            if (ipAddress.indexOf(",") > 0) {
                ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
            }
        }
        return ipAddress;
    }
public static String remoteIP(HttpServletRequest request) {
        String ipAddress;
        ipAddress = request.getHeader("x-forwarded-for");
        if ((ipAddress == null) || (ipAddress.length() == 0)
                || ("unknown".equalsIgnoreCase(ipAddress))) {
            ipAddress = request.getHeader("Proxy-Client-IP");
        }
        if ((ipAddress == null) || (ipAddress.length() == 0)
                || ("unknown".equalsIgnoreCase(ipAddress))) {
            ipAddress = request.getHeader("WL-Proxy-Client-IP");
        }
        if ((ipAddress == null) || (ipAddress.length() == 0)
                || ("unknown".equalsIgnoreCase(ipAddress))) {
            ipAddress = request.getRemoteAddr();
            if (ipAddress.equals("127.0.0.1")) {
                InetAddress inet;
                try {
                    inet = InetAddress.getLocalHost();
                    ipAddress = inet.getHostAddress();
                } catch (UnknownHostException e) {
                    e.printStackTrace();
                }
            }
        }
        if ((ipAddress != null) && (ipAddress.length() > 15)) {
            if (ipAddress.indexOf(",") > 0) {
                ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
            }
        }
        return ipAddress;
    }
public static String remoteIP ( HttpServletRequest request ) { String ipAddress ; ipAddress = request . getHeader ( "x-forwarded-for" ) ; if ( ( ipAddress == null ) || ( ipAddress . length ( ) == 0 ) || ( "unknown" . equalsIgnoreCase ( ipAddress ) ) ) { ipAddress = request . getHeader ( "Proxy-Client-IP" ) ; } if ( ( ipAddress == null ) || ( ipAddress . length ( ) == 0 ) || ( "unknown" . equalsIgnoreCase ( ipAddress ) ) ) { ipAddress = request . getHeader ( "WL-Proxy-Client-IP" ) ; } if ( ( ipAddress == null ) || ( ipAddress . length ( ) == 0 ) || ( "unknown" . equalsIgnoreCase ( ipAddress ) ) ) { ipAddress = request . getRemoteAddr ( ) ; if ( ipAddress . equals ( "127.0.0.1" ) ) { InetAddress inet ; try { inet = InetAddress . getLocalHost ( ) ; ipAddress = inet . getHostAddress ( ) ; } catch ( UnknownHostException e ) { e . printStackTrace ( ) ; } } } if ( ( ipAddress != null ) && ( ipAddress . length ( ) > 15 ) ) { if ( ipAddress . indexOf ( "," ) > 0 ) { ipAddress = ipAddress . substring ( 0 , ipAddress . indexOf ( "," ) ) ; } } return ipAddress ; }
获取客户端IP地址，此方法用在proxy环境中

@param request 当前请求
@return 客户端ip，如果获取失败，则返回 127.0.0.1
获取客户端IP地址，此方法用在proxy环境中