java ServletRequest,获取访问者IP

aar8387 2016-10-18 05:50:33

如图,通过该方法获取到的ip一直是127.0.0.1,一直找不到原因,谁能解答下吗,谢谢!
...全文
431 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
piterlin 2016-10-18
  • 打赏
  • 举报
回复
把浏览器访问该页面的url从原来的http://127.0.0.1:*改为http://192.1*(内网或公网IP)试试。 原文: java.lang.String getRemoteHost() Returns the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address. For HTTP servlets, same as the value of the CGI variable REMOTE_HOST. 参考:http://www.coderhelper.top/doc/tomcat-9.0-doc/servletapi/index.html

50,530

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧