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)
posted @   鸭梨的药丸哥  阅读(19)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示