spring - Spring @GetMapping 不适用于子资源
问题描述
我有一个控制器,看起来像这样。
@RestController("/some")
public class SomeController {
@GetMapping(produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> read(...) {
...
}
@GetMapping(path = "{id:\\d+}", produces = ...)
public ResponseEntity<Some> readSingle(@PathVariable(name = "id") final int id) {
...
}
}
控制器适用于父母。
curl http://.../some
但子资源返回与 相同/some
。
curl http://.../some/2 // returns the same with /some
我做错了什么?
解决方案
我正在回答我自己的问题。
问题是类上的错误注释。
@RequestMapping(path = {...})
@RestController
public class SomeController {
}
推荐阅读
- python - 如何在不提及其父文件夹的情况下导入python文件
- javascript - 在angularjs中读取表单输入的文件内容
- r - 闪亮的情节没有出现
- php - 未定义索引:jawaban
- c++ - C++ - 通用结构的成员在分配双精度时给出错误的值(但适用于整数)
- python - 使用 cloud9 将 aws lambda 部署到另一个区域的最佳实践
- python - 日期不一致
- git - Jenkins:无法连接到 Git 存储库
- hive - Nifi 中的 PutHiveStreaming 处理器抛出 NPE
- python - Google IAP 不断响应 401 Unauthorized