当前位置:网站首页>How does JSP use request to get the real IP of the current visitor?
How does JSP use request to get the real IP of the current visitor?
2022-08-02 00:18:00 【qq_25073223】
From:
How does JSP use request to obtain the currentWhat about the real IP of the visitor?
The following describes the method to obtain the real IP of the visitor, as follows:
When using a reverse proxy, we <%=request.getRemoteAddr() %>, it will return 127.0.0.1So how do you get the visitor's IP information?The following will come one by one, as follows:Implementation ideas:Get a visitor's real IP with the help of the following methods public String getIpAddr(HttpServletRequest request) {String ip = request.getHeader("x-forwarded-for");if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {ip = request.getHeader("Proxy-Client-IP");}if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {ip = request.getHeader("WL-Proxy-Client-IP");}if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {ip = request.getRemoteAddr();}return ip;}边栏推荐
猜你喜欢
随机推荐
LeetCode_279_完全平方数
很多人喜欢用多御安全浏览器,竟是因为这些原因
【Leetcode】473. Matchsticks to Square
接地气讲解TCP协议和网络程序设计
Ansible中的任务执行控制
els 方块边界变形处理
面试必问的HashCode技术内幕
TCL: Pin Constraints Using the tcl Scripting Language in Quartus
一篇永久摆脱Mysql时区错误问题,idea数据库可视化插件配置
Detailed explanation of Zadig's self-testing and tuning environment technical solution for developers
IP Core: FIFO
链上治理为何如此重要,波卡Gov 2.0又会如何引领链上治理的发展?
【Leetcode】1206. Design Skiplist
短视频seo搜索优化主要内容
thinkphp漏洞总结
零基础如何学习单片机,一位入门者的进阶路径,可参考
Study Notes: The Return of Machine Learning
security CSRF Vulnerability Protection
Zadig 面向开发者的自测联调子环境技术方案详解
SphereEx Miao Liyao: Database Mesh R&D Practice under Cloud Native Architecture









