ResponseEntity and HTTP status codes

ResponseEntity<T> represents a complete HTTP response in Spring: status code, headers, and body. It lets you choose the appropriate status (201 Created with the Location header, 204 No Content, 404 Not Found) instead of the default 200.

Example

return ResponseEntity.status(HttpStatus.CREATED).body(client);

Related concepts

The whole glossary