spring ResponseEntity
生活随笔
收集整理的這篇文章主要介紹了
spring ResponseEntity
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
spring ResponseEntity
1. 用途
? ResponseEntity用于后臺服務返回給前端發送數據的格式化。開始的時候,我們用json包生產一個json的字符串,配合http 協議的一些API 來自定義實現,但如今spring已經都包裝出來了通用的處理類:ResponseEntity ,此類繼承自HttpEntity,并且做了擴展,用來處理http請求過程中的狀態碼 ,header,body 等數據。
2. 關于使用
ResponseEntity的構造函數:
public ResponseEntity(HttpStatus status) public ResponseEntity(@Nullable T body, HttpStatus status) public ResponseEntity(MultiValueMap<String, String> headers, HttpStatus status) public ResponseEntity(@Nullable T body, @Nullable MultiValueMap<String, String> headers, HttpStatus status)總結
以上是生活随笔為你收集整理的spring ResponseEntity的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java Semaphore 信号量
- 下一篇: Galera 核心参数详解(一)