posts - 41, comments - 15, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          日歷

          <2012年1月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          2930311234

          文章檔案

          搜索

          •  

          獲取客戶端和服務器ip地址

          Posted on 2012-01-17 11:01 yuhaibo736 閱讀(823) 評論(0)  編輯  收藏

          //獲取客戶端ip地址

                   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;

                    }

           

          //獲取服務器ip地址

                   InetAddress inet = InetAddress.getLocalHost();

                   String hostAddress=inet.getHostAddress();


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 襄垣县| 穆棱市| 贵港市| 屯门区| 普洱| 玛多县| 唐山市| 栖霞市| 通江县| 喀什市| 杂多县| 离岛区| 平陆县| 五台县| 宁明县| 横山县| 尉犁县| 博白县| 沅江市| 五台县| 门头沟区| 霸州市| 左贡县| 襄城县| 垣曲县| 米易县| 丰顺县| 专栏| 汉川市| 青海省| 嵊泗县| 色达县| 北安市| 巫溪县| 望都县| 棋牌| 肇州县| 龙岩市| 枝江市| 自贡市| 昆明市|