亚洲国产成人,色呦呦内射午夜,无码一级片,无码人妻少妇色欲AV一区二区

<samp id="jg8hh"></samp>

<p id="jg8hh"></p><delect id="jg8hh"><em id="jg8hh"><blockquote id="jg8hh"></blockquote></em></delect><acronym id="jg8hh"><dd id="jg8hh"></dd></acronym><button id="jg8hh"><dd id="jg8hh"><acronym id="jg8hh"></acronym></dd></button><samp id="jg8hh"><em id="jg8hh"><blockquote id="jg8hh"></blockquote></em></samp>

<p id="jg8hh"></p>

<samp id="jg8hh"><legend id="jg8hh"></legend></samp>
<samp id="jg8hh"><legend id="jg8hh"><samp id="jg8hh"></samp></legend></samp>

<samp id="jg8hh"></samp>

<p id="jg8hh"></p><acronym id="jg8hh"></acronym><p id="jg8hh"><dd id="jg8hh"><acronym id="jg8hh"></acronym></dd></p><p id="jg8hh"></p>

<p id="jg8hh"></p><delect id="jg8hh"><legend id="jg8hh"><var id="jg8hh"></var></legend></delect><button id="jg8hh"><listing id="jg8hh"><i id="jg8hh"></i></listing></button>
<delect id="jg8hh"><legend id="jg8hh"><var id="jg8hh"></var></legend></delect>

java實現(xiàn)判斷ip是否在指定ip區(qū)間的工具類

發(fā)布時間:2024-09-01
思路:
利用ip和ip區(qū)間兩端的值調(diào)用ipisvalid方法。
(視頻教程推薦:java課程)
工具類:
import org.apache.commons.lang.stringutils;import org.springframework.web.context.request.requestcontextholder;import org.springframework.web.context.request.servletrequestattributes;import javax.servlet.http.httpservletrequest;public class iputil { / * 獲得當前ip * @return */ public static string getip(){ servletrequestattributes servletrequestattributes = (servletrequestattributes) requestcontextholder.getrequestattributes(); if(servletrequestattributes == null) { return "127.0.0.1"; } httpservletrequest request = servletrequestattributes.getrequest(); 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.getheader("http_client_ip"); } if (ip == null || ip.length() == 0 || "unknown".equalsignorecase(ip)) { ip = request.getheader("http_x_forwarded_for"); } if (ip == null || ip.length() == 0 || "unknown".equalsignorecase(ip)) { ip = request.getremoteaddr(); } if ("0:0:0:0:0:0:0:1".equals(ip)) { ip = "127.0.0.1"; } return ip; } / * 判斷ip是否在指定范圍 * @param ipstart * @param ipend * @param ip * @return */ public static boolean ipisvalid(string ipstart,string ipend, string ip) { if (stringutils.isempty(ipstart)) { throw new nullpointerexception("起始ip不能為空!"); } if (stringutils.isempty(ipend)) { throw new nullpointerexception("結(jié)束ip不能為空!"); } if (stringutils.isempty(ip)) { throw new nullpointerexception("ip不能為空!"); } ipstart = ipstart.trim(); ipend = ipend.trim(); ip = ip.trim(); final string regx_ip = "((25[0-5]|2[0-4]\\\\\\\\d|1\\\\\\\\d{2}|[1-9]\\\\\\\\d|\\\\\\\\d)\\\\\\\\.){3}(25[0-5]|2[0-4]\\\\\\\\d|1\\\\\\\\d{2}|[1-9]\\\\\\\\d|\\\\\\\\d)"; final string regx_ipb = regx_ip "\\\\\\\\-" regx_ip; if (!ipstart.matches(regx_ip) || !ip.matches(regx_ip) || !ipend.matches(regx_ip)) { return false; } string[] sips = ipstart.split("\\\\\\\\."); string[] sipe = ipend.split("\\\\\\\\."); string[] sipt = ip.split("\\\\\\\\."); long ips = 0l, ipe = 0l, ipt = 0l; for (int i = 0; i < 4; i) { ips = ips << 8 | integer.parseint(sips[i]); ipe = ipe << 8 | integer.parseint(sipe[i]); ipt = ipt << 8 | integer.parseint(sipt[i]); } if (ips > ipe) { long t = ips; ips = ipe; ipe = t; } return ips <= ipt && ipt <= ipe; }} 相關(guān)教程推薦:java入門教程
上一個:軸承加熱器有哪些優(yōu)勢
下一個:在安裝靜電水處理器之前看看本篇會很有幫助

埃斯頓擬授出1000萬份股票期權(quán)
恒溫水浴鍋的工作原理及操作維護保養(yǎng)的注意事項
日喀則空運(成都物流空運日喀則)
小米3怎么取消拒絕來電,小米怎么取消自動拒絕
變壓器線圈直阻快測儀技術(shù)指標
電纜如何在海底敷設(shè)?
一文看懂三通角閥機床的優(yōu)勢
dichtomatiko型圈油封等配件產(chǎn)品全方位解析(滿足多領(lǐng)域需求)
防腐風(fēng)機對使用電機的要求
RC1206FR-07133KL,1206 133KΩ 1% 1/4W 電阻