@GetMapping
和 @RequestMapping(method = RequestMethod.GET)
有什么区别?
我在一些 Spring Reactive 示例中看到,使用 @GetMapping
代替 @RequestMapping
原文由 nowszy94 发布,翻译遵循 CC BY-SA 4.0 许可协议
@GetMapping
和 @RequestMapping(method = RequestMethod.GET)
有什么区别?
我在一些 Spring Reactive 示例中看到,使用 @GetMapping
代替 @RequestMapping
原文由 nowszy94 发布,翻译遵循 CC BY-SA 4.0 许可协议
8 回答6.6k 阅读
4 回答717 阅读✓ 已解决
2 回答3.4k 阅读
3 回答1.9k 阅读✓ 已解决
1 回答2.2k 阅读✓ 已解决
1 回答2.1k 阅读✓ 已解决
1 回答974 阅读✓ 已解决
@GetMapping
是一个组合注释,充当@RequestMapping(method = RequestMethod.GET)
的快捷方式。@GetMapping
是较新的注释。它支持消费消费选项是:
消耗=“文本/普通”
消耗 = {“text/plain”, “application/*”}
有关更多详细信息,请参阅: GetMapping 注解
或阅读: 请求映射变体
RequestMapping 也支持消费
GetMapping 我们只能在方法级别应用,而 RequestMapping 注释我们可以在类级别和方法级别应用