当前位置:网站首页>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;}}边栏推荐
- flink sql任务变更,在sql里面增加几个字段后,从以前保存的savepoint恢复启动出错。
- redis键值出现 xacxedx00x05tx00&的解决方法
- 【精讲】利用原生js实现todolist
- Technology Sharing | How to do assertion verification for xml format in interface automation testing?
- 汇编题答案
- install ambari
- rosbag工具plotjuggler无法打开rosbag的问题
- Super handy drawing tool is recommended
- 社交电商如何做粉丝运营?云平台怎么选择商业模式?
- 【Harmony OS】【FAQ】Hongmeng Questions Collection 1
猜你喜欢

IO进程线程->线程->day5

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

How to use the interface management tool YApi?Beautiful, easy to manage, super easy to use

4.深度学习的几何解释与梯度的优化

接口测试实战| GET/POST 请求区别详解

UV 裂解的生物素-PEG2-叠氮|CAS:1192802-98-4生物素接头

接口和协议

深圳线下报名|StarRocks on AWS:如何对实时数仓进行极速统一分析

mysql 创建索引的三种方式

Windows 安装PostgreSQL
随机推荐
数字孪生园区场景中的坐标知识
1.一个神经网络示例
The flink sql task is changed, and after adding several fields to the sql, an error occurs when restoring from the previously saved savepoint.
2022 Henan Mengxin League Game (4): Zhengzhou University of Light Industry E - Sleep Well
Test drive: project management module - curd development project
Record some bugs encountered - when mapstruct and lombok are used at the same time, the problem of data loss when converting entity classes
2022河南萌新联赛第(四)场:郑州轻工业大学 E - 睡大觉
表的创建、修改与删除
测开:项目管理模块-项目curd开发
13.机器学习基础:数据预处理与特征工程
打破传统电商格局,新型社交电商到底有什么优点?
Jmeter 模拟多用户登录的两种方法
技术分享 | 接口自动化测试中如何对xml 格式做断言验证?
接口和协议
Where is the value of testers
工程水文学试题库
MOSN 反向通道详解
Interface testing framework combat (3) | JSON request and response assertion
12.机器学习基础:评估机器学习模型
深圳线下报名|StarRocks on AWS:如何对实时数仓进行极速统一分析