2016-08-22 196 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

相關問題