/**
* 得到请求的IP地址
*
* @param request
* @return
*/
public static String getIp(HttpServletRequest request) {
String ip = request.getHeader("X-Real-IP");
if (StringUtils.isBlank(ip)) {
ip = request.getHeader("Host");
}
if (StringUtils.isBlank(ip)) {
ip = request.getHeader("X-Forwarded-For");
}
if (StringUtils.isBlank(ip)) {
ip = "0.0.0.0";
}
return ip;
}
转载于:https://my.oschina.net/sxdtzhaoxinguo/blog/736968