JERSEY: How to retrieve the calling IP or URI using injection annotation?

后端 未结 3 1855
生来不讨喜
生来不讨喜 2021-02-13 10:28

I have a REST- Server here using JERSEY. I must log the IP (better the DNS) of the calling client.

Can somebody point a direction which injection annotations to use ?

3条回答
  •  没有蜡笔的小新
    2021-02-13 11:01

    you could add @Context HttpServletRequest request as a parameter to your request handler method. And then get a hold of the client IP with request.getRemoteAddr()

提交回复
热议问题