DO NOT directly send response body content. Instead, wrap it in a ResponseEntity
object, which represents the entire HTTP response (status code, header/s, body).
o.s.http.ResponseEntity<T>
: A generic class.T
: Type of the response body.Constructor:
ResponseEntity(T body, HttpStatus status);
HttpStatus
: Enum containing response status codes (1XX to 5XX).OR Methods:
ResponseEntity.status(HttpStatus status).body(T body)
HttpStatus
: Enum containing status codes from 1xx to 5xx series.