java如何在一个rest api中形成多个get请求?
我的代码中有以下get请求:
@GetMapping
public ArrayList<Response> getGeneralResponses() {
return requestService.getGeneralResponses();
}
@GetMapping
public ArrayList<Response> getWinningResponses() {
return requestService.getWinningResponses();
}
我如何拨打仅激活其中一种方法的get电话?例如,我想进行一个get调用,只激活“getWinningResponses()”方法。我在用邮递员做测试
请简单地解释一下,我对spring和api都非常、非常陌生
# 1 楼答案
这是一个非常普通的简化(我非常推荐一个教程[例如Baeldung],更不用说阅读官方文件):
在类注释和/或方法注释中指定端点(指向公开资源的路径):
这样,如果你的应用程序在端口
8080
上运行,在访问http://localhost:8080/path1
之后,你会看到Hello
和http://localhost:8080/path1/path2
-Another