@getMapping與@postMapping


首先要了解一下@RequestMapping注解。

  @RequestMapping用於映射url到控制器類的一個特定處理程序方法。可用於方法或者類上面。也就是可以通過url找到對應的方法。

  @RequestMapping有8個屬性。

value:指定請求的實際地址。

method:指定請求的method類型(GET,POST,PUT,DELETE)等。

consumes:指定處理請求的提交內容類型(Context-Type)。

produces:指定返回的內容類型,還可以設置返回值的字符編碼。

params:指定request中必須包含某些參數值,才讓該方法處理。

headers:指定request中必須包含某些指定的header值,才讓該方法處理請求。

 

@getMapping與@postMapping是組合注解。

@getMapping = @requestMapping(method = RequestMethod.GET)。

@postMapping = @requestMapping(method = RequestMethod.POST)。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM