2016-08-22 131 views

回答

74

@GetMapping是一个组合注释,可作为@RequestMapping(method = RequestMethod.GET)的快捷键。

@GetMapping是更新的注释。 它支持消耗

消耗选项是:

消耗= “text/plain的”
消耗= { “text/plain的”, “应用/ *”}

进一步的细节参见: GetMapping Annotation

或阅读: request mapping variants

RequestMapping支持消耗以及

+0

'@ GetMapping'支持'consumes' - http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/bind/annotation/GetMapping.html#consumes-- – whoami

+0

RequestMapping也支持消耗:https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/bind/annotation/RequestMapping.html#consumes-- –

7

,而不是如你所见here

具体来说,@GetMapping是充当一个 快捷的组成注释@RequestMapping(method = RequestMethod.GET)

差异& @GetMapping之间@GetMapping@RequestMapping

不支持 @RequestMappingconsumes属性。

+11

好消息!截至2017年4月,在您链接到的Spring网页上,GetMapping * does *现在支持'消耗'和通常的RequestMapping属性。可能Spring会在你的帖子后添加这些内容。 – devdanke

相关问题