怎么解决Spring本地请求ip地址 0:0:0:0:0:0:0:1
·
本地请求spring项目的时候,获取请求的ip地址,假如你的写法是:
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getRemoteAddr()
1.如果的请求是用的 localhost
对应的值就是: 0:0:0:0:0:0:0:1

2.如果的请求是用的 127.0.0.1
http://localhost:8080/xxxx127.0.0.1http://localhost:8080/xxxx
对应的值就是: 127.0.0.1
3.如果的请求是用的 本机实际ip

对应的值就是: x.x.x.x
更多推荐
所有评论(0)