简体   繁体   中英

RESTEasy and client IP address

I'm using RESTEasy services in my application and now I'm forced to get the clients IP addresses. So the question is... how can I do that?. Thanks in advance

EDITED I've just came to a solution with servlet filter... but still.. can that be done inside of RESTEasy service?

You can annotate a Context in your resource like this:

@GET
@Path("/{id}")
public Response getMe(
            final @PathParam("id") String id,
            @Context HttpServletRequest req) {

     System.err.println(req.getRemoteAddr());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM