how to get users ip address in java

前端 未结 2 916
忘了有多久
忘了有多久 2021-01-15 00:38

While this may seem simple, i have tried the usual request.getRemoteAddr(), request.getRemoteHost() but i keep getting my servers address. Something about my configuration,

2条回答
  •  遥遥无期
    2021-01-15 01:22

    If there's some proxy between you and the user, then you might have to look at the X-Forwarded-For header. Note that this isn't guaranteed to work either, but if you only need "good enough", then it might suffice.

提交回复
热议问题