标签:blog http ar sp for java art log bs
public class IpUtils{ /** * 获取ip地址 * @param request * @return */ public static String getIpAddr(HttpServletRequest request) { String ip = request.getHeader("x-forwarded-for"); if (ip != null && !ip.isEmpty()) { ip = ip.split(",")[0].trim(); } 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获取地理位置/天气信息等:
http://www.jb51.net/article/54287.htm
http://blog.csdn.net/wssiqi/article/details/8550951
标签:blog http ar sp for java art log bs
原文地址:http://my.oschina.net/u/2001537/blog/356318