request获取真实IP

public String getRemoteIP() {
String ip = request.getRemoteAddr();
if (request.getHeader("x-forwarded-for") != null
&& !"unknown".equalsIgnoreCase(request
.getHeader("x-forwarded-for"))) {
ip = ip + "," + request.getHeader("x-forwarded-for");
}
return ip;
}

posted @ 2015-12-01 11:49  王八一瓶子  阅读(379)  评论(0编辑  收藏  举报