欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

java获取注册ip实例

程序员文章站 2024-03-09 10:13:11
话不多说,请看实例代码 string ip = request.getheader("x-forwarded-for"); if (ip == nu...

话不多说,请看实例代码

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();
      }
      system.out.println("ip:"+ip);

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!