[英]RESTEasy and client IP address
I'm using RESTEasy services in my application and now I'm forced to get the clients IP addresses. 我在应用程序中使用RESTEasy服务,现在不得不获取客户端IP地址。 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? 编辑我刚刚来到了一个带有servlet过滤器的解决方案...但是还是..可以在RESTEasy服务内部完成吗?
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());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.