文件名称:org.apache.commons.lang3.StringUtils.jar
文件大小:4.02MB
文件格式:RAR
更新时间:2022-12-29 05:04:36
StringUtils java
java获取客户端ip(经过多次代理)提示StringUtils cannot be resolved 需要先 import org.apache.commons.lang3.StringUtils; /* 内含 common-lang3.jar commons-lang3-3.9-bin.zip commons-lang3-3.9-src.zip 使用说明.txt*/ public static String getClientIp(HttpServletRequest request) { String ip = request.getHeader("X-Forwarded-For"); if (!StringUtils.isEmpty(ip) && !"unKnown".equalsIgnoreCase(ip)) { //多次反向代理后会有多个ip值,第一个ip才是真实ip int index = ip.indexOf(","); if (index != -1) { return ip.substring(0, index); } else { return ip; } } ip = request.getHeader("X-Real-IP"); if (!StringUtils.isEmpty(ip) && !"unKnown".equalsIgnoreCase(ip)) { return ip; } return request.getRemoteAddr(); }
【文件预览】:
commons.lang3.StringUtils.jar
----使用说明.txt(235B)
----commons-lang3-3.9-src.zip(1.3MB)
----commons-lang3-3.9-bin.zip(2.24MB)
----common-lang3.jar(632KB)