当前位置:网站首页>Get the Ip tool class
Get the Ip tool class
2022-08-03 04:40:00 【Dzooooone_】
public class IPUtil {public static String getIpAddress(HttpServletRequest request) {String 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") || ipAddress.equals("0:0:0:0:0:0:0:1")) {// Get the IP configured by the machine according to the network cardInetAddress inet = null;try {inet = InetAddress.getLocalHost();} catch (UnknownHostException e) {e.printStackTrace();}ipAddress = inet.getHostAddress();}}// For the case of passing through multiple proxies, the first IP is the real IP of the client, and multiple IPs are divided according to ','if (ipAddress != null && ipAddress.length() > 15) { // "***.***.***.***".length() = 15if (ipAddress.indexOf(",") > 0) {ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));}}return ipAddress;}}边栏推荐
猜你喜欢

中断系统需要解决的问题

I ported GuiLite to STM32F4 board

OSI的分层特点、传输过程与三次握手、四次挥手、tcp与udp包头的描述

DDL操作数据库、表、列

私域流量引流方法?分享购火爆的商业模式,你值得拥有

2022/08/02 Study Notes (day22) Multithreading

Harmony OS ets ArkUI 】 【 】 the development basic page layout and data connection

OpenFOAM extracts equivalency and calculates area

多肽介导PEG磷脂——靶向功能材料之DSPE-PEG-RGD/TAT/NGR/APRPG

Can Oracle EMCC be installed independently?Or does it have to be installed on the database server?
随机推荐
【Harmony OS】【ArkUI】ets开发 基础页面布局与数据连接
移动流量的爆发式增长,社交电商如何选择商业模式
2022/08/02 学习笔记 (day22) 多线程
修饰生物素DIAZO-生物素-PEG3-DBCO|重氮-生物素-三聚乙二醇-二苯基环辛炔
Browser listens for tab closing
Windows 安装PostgreSQL
私域流量时代来临,电商企业如何布局?
Flink状态
mysql bool盲注
刚上线就狂吸70W粉,新型商业模式“分享购”来了,你知道吗?
Test drive: project management module - curd development project
接口测试 Mock 实战(二) | 结合 jq 完成批量化的手工 Mock
Can Oracle EMCC be installed independently?Or does it have to be installed on the database server?
WebSocket的实际应用
2022河南萌新联赛第(四)场:郑州轻工业大学 E - 睡大觉
社交电商:链动2+1模式,为什么能在电商行业生存那么久?
[Developers must see] [push kit] Collection of typical problems of push service service 2
OpenFOAM extracts equivalency and calculates area
获取Ip工具类
MOSN 反向通道详解