ResponseEntity
Learn ResponseEntity (REST API Development, Spring Boot) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Why ResponseEntity Exists If a controller method returns a plain object, Spring always answers 200 OK with that object as the body. That is fine for a simple read. But a real API needs to say "201 Created, here is where it lives", or "404, there is no such book", or add a header. ResponseEntity<T> lets the method return the whole response : status code, headers and body.
More lessons in REST API Development
- REST API & RESTful Web Services
- HTTP Methods
- HTTP Status Codes
- Building REST APIs with Spring Boot
- Request Mapping Annotations
- Reading Request Data
- DTOs: Request and Response
- API Design - Pagination, Filtering & Versioning
- JSON - Structure & Parsing
- REST API - Save & Update Operation
- REST API - Get & Delete Operation
- Spring Boot - Interceptor
- Mini Project: Book Catalogue REST API