前言
- 为什么这篇又不是Spring Boot初体验,因为在初体验过程中,我使用的方法返回值类型并不是基本数据类型,也不是String,而是用了ResponseEntity,为了避免有些人看不懂,在这篇做个ResponseEntity的源码浅析。
- 主要浅析ResponseEntity.ok方法的源码
- 本文是基于Spring5源码进行浅析
- 本文及以后文章中的 API 指的是API文档描述
ResponseEntity.class
让我们打开ResponseEntity.class
嗯。可以说是非常的清爽了;一个注释文档都没看到┑( ̄Д  ̄)┍
无奈;只好上官网找API:ResponseEntity API
ResponseEntity概念
Extension of
HttpEntity
that adds aHttpStatus
status code. Used inRestTemplate
as well@Controller
methods.
以上引用自