JAVA WEB 約定

各種請求方式的作用

參考 Spring Date RestHTTP中put,patch,post的區別(DRF)

  • GET 獲取
  • POST 提交新文檔
  • PUT 修改一個文檔,準確來說 SaveOrUpdate。存在則替換
  • PATCH 是對PUT方法的補充,用來對已知資源進行局部更新,PATCH是冪等的。
  • DELETE 刪除

返回狀態碼

參考 : Spring Date Rest :Default Status Codes
Default Status Codes

For the resources exposed, we use a set of default status codes:

200 OK: For plain GET requests.

201 Created: For POST and PUT requests that create new resources.

204 No Content: For PUT, PATCH, and DELETE requests when the configuration is set to not return response bodies for resource updates (RepositoryRestConfiguration.returnBodyOnUpdate). If the configuration value is set to include responses for PUT, 200 OK is returned for updates, and 201 Created is returned for resource created through PUT.

If the configuration values (RepositoryRestConfiguration.returnBodyOnUpdate and RepositoryRestConfiguration.returnBodyCreate) are explicitly set to null, the presence of the HTTP Accept header is used to determine the response code.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章