当前位置:网站首页>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;}}边栏推荐
- StarRocks July Community Update
- UV 裂解的生物素-PEG2-叠氮|CAS:1192802-98-4生物素接头
- 【Harmony OS】【ARK UI】轻量级数据存储
- CobalStrike(CS)基础超级详细版
- Record some bugs encountered - when mapstruct and lombok are used at the same time, the problem of data loss when converting entity classes
- DFS对剪枝的补充
- Test drive: project management module - curd development project
- How to use the interface management tool YApi?Beautiful, easy to manage, super easy to use
- 【Harmony OS】【ARK UI】ets使用startAbility或startAbilityForResult方式调起Ability
- mysql 创建索引的三种方式
猜你喜欢

Record some bugs encountered - when mapstruct and lombok are used at the same time, the problem of data loss when converting entity classes

私域流量时代来临,电商企业如何布局?

汇编题答案

工程水文学试题库

【HMS core】【Ads Kit】华为广告——海外应用在国内测试正式广告无法展示

Bubble sort in c language structure

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

unity2D横板游戏教程6-敌人AI以及受击动画

Redis缓存雪崩、缓存穿透、缓存击穿

BIOTIN ALKYNE CAS:773888-45-2价格,供应商
随机推荐
「短视频+社交电商」营销模式爆发式发展,带来的好处有什么?
三丁基-巯基膦烷「tBuBrettPhos Pd(allyl)」OTf),1798782-17-8
How to use the interface management tool YApi?Beautiful, easy to manage, super easy to use
Two ways to simulate multi-user login in Jmeter
"Obs" start pushing flow failure: the Output. The StartStreamFailed call process
online test paper concept
Record some bugs encountered - when mapstruct and lombok are used at the same time, the problem of data loss when converting entity classes
社交电商:链动2+1模式,为什么能在电商行业生存那么久?
How many moments have you experienced the collapse of electronic engineers?
Flink state
mysql bool盲注
UV 裂解的生物素-PEG2-叠氮|CAS:1192802-98-4生物素接头
【Harmony OS】【ARK UI】Date 基本操作
普乐蛙VR台风体验馆厂家VR防震减灾模拟VR沉浸式体验设备
Interface Test Framework Practice (4) | Get Schema Assertion
【Harmony OS】【ArkUI】ets开发 图形与动画绘制
OpenFOAM extracts equivalency and calculates area
测开:项目管理模块-项目curd开发
数字化时代,企业如何建立自身的云平台与商业模式的选择?
好消息!北京、珠海PMP考试时间来啦