【发布时间】:2013-09-22 14:52:41
【问题描述】:
我正在尝试使用此获取远程 IP:
String remoteAddress = ((ServletRequestAttributes) RequestContextHolder
.currentRequestAttributes()).getRequest().getRemoteAddr();
我在控制器中调用它,但它返回0:0:0:0:0:0:0:1。怎么了?
【问题讨论】:
-
您是从本地(主机)浏览器访问 Web 应用程序吗?
-
您的 servlet 容器前面是否有反向代理(如 Nginx 或 Apache Web 服务器)?