同一球衣REST API类的多个根路径

发布于 2025-02-05 11:34:50 字数 295 浏览 2 评论 0原文

我有一个带有以下根路径的球衣REST API类

@Path(/v1/{start}/resource)
public class classA{

//Business logic

}

,现在我有一个要求,我需要还有一个指向同一REST类的路径,即有两个路径指向相同的REST类,例如:

两个端点/ V1/start/resource/start/resource应击中上面给定的REST类。

有什么方法可以实现这一目标吗?

I have a Jersey REST API class with following root path

@Path(/v1/{start}/resource)
public class classA{

//Business logic

}

Now I have a requirement where I need to have one more path which points to same REST class, i.e have two paths pointing to same rest class, for example:

Both endpoints /v1/start/resource and /start/resource should hit the same above given rest class.

Is there any way to achieve this?

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

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

发布评论

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

评论(1

給妳壹絲溫柔 2025-02-12 11:34:50

好的,我在@path注释中使用regx找到了一个解决方案,如下所示:

@Path("/{ver : (v1/)?}{start}/resource")
public class classA{

//Business logic

}

“/{ver :( v1/)?} {start}/resource”将解决两种> /v1/start/resource或<代码>/start/resource

Okay, I found a solution for this using Regx in the @Path annotation as follows:

@Path("/{ver : (v1/)?}{start}/resource")
public class classA{

//Business logic

}

The "/{ver : (v1/)?}{start}/resource" will resolve to both /v1/start/resource or /start/resource

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