RESTeasy如何解决@Path冲突
考虑上面的代码
@Path("a")
@Produces("text/plain")
public class A {
@GET
@Path("a")
public String getA() {
return "a";
}
@GET
@Path("a")
public String getB() {
return "b";
}
}
请求 http://host/a/a 我总是得到“b”。
选择适当方法的策略是什么? 有什么方法可以了解通往不同资源的多个路径吗?
Consider the code above
@Path("a")
@Produces("text/plain")
public class A {
@GET
@Path("a")
public String getA() {
return "a";
}
@GET
@Path("a")
public String getB() {
return "b";
}
}
Requesting http://host/a/a i always get "b".
What is the strategy to select the appropiated method ?
Any way to get informed about multiple paths to diferent resources ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据评论进一步编辑,
我不知道 RESTEasy 中是否有任何报告工具可以提供跨一系列带注释的服务类的重复匹配模式列表。但是,您可以使用以下方法之一解决此问题:
编辑以更好地定位问题
RESTEasy 使用 基于正则表达式的路径系统并选择最接近匹配的模式。如果发生碰撞,将使用最后一个匹配的。
Further edited in light of the comment
I don't know of any reporting tool within RESTEasy that offers a list of duplicated matching patterns across a range of annotated service classes. However, you could approach this problem using one of the following methods:
Edited to better target the question
RESTEasy uses a regex based system for paths and selects the most closely matching pattern. In the event of a collision the last one matched is used.