RESTEasy 和客户端 IP 地址

发布于 2024-09-18 11:25:32 字数 162 浏览 2 评论 0原文

我在我的应用程序中使用 RESTEasy 服务,现在我被迫获取客户端 IP 地址。所以问题是...我怎样才能做到这一点? 提前致谢

已编辑 我刚刚找到了一个带有 servlet 过滤器的解决方案...但是仍然...可以在 RESTEasy 服务内部完成吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

两相知 2024-09-25 11:25:32

您可以在资源中注释上下文,如下所示:

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

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

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());
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文