您的位置:首页 > 其它

获取系统的一些信息汇总

2013-04-26 15:55 225 查看
1、获取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;

       }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: