NutzCN Logo
问答 登录获取ip问题 127.0.0.1
发布于 2491天前 作者 wx_dc1uhcoqb670vfspa24d 2843 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk
Subject subject = SecurityUtils.getSubject();
Sys_user user = (Sys_user) subject.getPrincipal();
String ip = user.getLoginIp();

发现 部署到服务器 一直显示,127.0.0.1

我应该怎么获取用户的真实访问ip呢?

4 回复
 ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 100.0.112.43  netmask 255.255.0.0  broadcast 13.0.255.255
        ether 00:16:3e:08:25:56  txqueuelen 1000  (Ethernet)
        RX packets 318268953  bytes 27707856340 (25.8 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 265394345  bytes 45484233592 (42.3 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1  (Local Loopback)
        RX packets 3295965  bytes 204358214 (194.8 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3295965  bytes 204358214 (194.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

服务器的ip

String ip = Lang.getIp(Mvcs.getReq());

嗷嗷 应该从当前的req中取ip,那shiro取得不是当前的ip吗?

你取的明显是数据库里的IP……

添加回复
请先登陆
回到顶部