当前位置:网站首页>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;}}边栏推荐
- DFS's complement to pruning
- 常见亲脂性细胞膜染料DiO, Dil, DiR, Did光谱图和实验操作流程
- Technology Sharing | How to do assertion verification for xml format in interface automation testing?
- OpenFOAM提取等职面并计算面积
- 传统企业如何转型社交电商,泰山众筹的玩法有哪些?
- 【Harmony OS】【ArkUI】ets开发 图形与动画绘制
- Unity2D horizontal board game tutorial 6 - enemy AI and attack animation
- 13.机器学习基础:数据预处理与特征工程
- UV 裂解的生物素-PEG2-叠氮|CAS:1192802-98-4生物素接头
- 2022/08/02 学习笔记 (day22) 多线程
猜你喜欢

StarRocks 7 月社区动态

BIOTIN ALKYNE CAS:773888-45-2价格,供应商

StarRocks July Community Update

【Harmony OS】【ARK UI】ETS 上下文基本操作

【Harmony OS】【ArkUI】ets开发 基础页面布局与数据连接

Unity2D horizontal board game tutorial 6 - enemy AI and attack animation

刚上线就狂吸70W粉,新型商业模式“分享购”来了,你知道吗?

Two ways to simulate multi-user login in Jmeter

Shenzhen Offline Registration|StarRocks on AWS: How to conduct rapid and unified analysis of real-time data warehouses

Where is the value of testers
随机推荐
11.机器学习基础:机器学习的四个分支
CyberArk被评为2022年Gartner特权访问管理魔力象限领导者
Test drive: project management module - curd development project
社交电商:链动2+1模式,为什么能在电商行业生存那么久?
DFS's complement to pruning
Concepts and Methods of Exploratory Testing
MOSN 反向通道详解
2022 Henan Mengxin League Game (4): Zhengzhou University of Light Industry E - Sleep Well
在线密码生成工具推荐
私域流量时代来临,电商企业如何布局?
【精讲】利用原生js实现todolist
我将GuiLite移植到了STM32F4开发板上
索引创建、删除与使用
UV 裂解的生物素-PEG2-叠氮|CAS:1192802-98-4生物素接头
用户密码验证
MySQL 出现 The table is full 的解决方法
OSI的分层特点、传输过程与三次握手、四次挥手、tcp与udp包头的描述
接口测试框架实战(四)| 搞定 Schema 断言
Windows 安装PostgreSQL
13.机器学习基础:数据预处理与特征工程