Skip to main content

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