How to get the client IP address in a JAX-RS resource class without injecting the HttpServletRequest?
问题 We are using JAX-RS 1.0 and I want to get the client IP address in my resource class. Currently I inject the HttpServletRequest as a method parameter and then get the IP address. I want to make my code cleaner. I am thinking if I can use a MessageBodyReader class and set the IP address. But if I use a MessageBodyReader I have to unmarshall the XML to a Java object which is additional logic as far as I believe. Can anyone please let me know how to get the client IP address without having to