java Dropwizard资源类调用另一个资源方法类?
我想知道在dropwizard中是否可以从不同的资源类调用另一个资源方法类
我查看了其他帖子,使用ResourceContext可以从另一个资源类调用get方法,但也可以从另一个资源类使用post方法
假设我们有两个资源类A和B。在类A中,我创建了一些JSON,我想使用B的post方法将JSON发布到B类。那可能吗
你可以在下面搜索框中键入要查询的问题!
我想知道在dropwizard中是否可以从不同的资源类调用另一个资源方法类
我查看了其他帖子,使用ResourceContext可以从另一个资源类调用get方法,但也可以从另一个资源类使用post方法
假设我们有两个资源类A和B。在类A中,我创建了一些JSON,我想使用B的post方法将JSON发布到B类。那可能吗
# 1 楼答案
是的,资源上下文可用于从相同或不同资源中的另一个方法访问
POST
和GET
方法在
@Context
的帮助下,您可以轻松访问这些方法现在,您可以通过以下方式从
Resource B
访问Resource A
的方法