美文网首页
服务端获取客户端ip

服务端获取客户端ip

作者: 乡村码农 | 来源:发表于2022-10-12 19:45 被阅读0次

    返回http请求的ip

    private String getRemoteIp(HttpServletRequest request) {
            String remoteAddr = request.getHeader("X-Forwarded-For");
            if (null == remoteAddr || "".equals(remoteAddr)) {
                remoteAddr = request.getRemoteAddr();
            }
            return remoteAddr;
        }
    

    相关文章

      网友评论

          本文标题:服务端获取客户端ip

          本文链接:https://www.haomeiwen.com/subject/lwcxzrtx.html