Class ResponseEntity<T>
java.lang.Object
com.bobocode.bring.web.servlet.http.ResponseEntity<T>
- Type Parameters:
T
- The type of the response body.
Represents an HTTP response entity, containing a response body, headers, and HTTP status.
When both
ResponseEntity
and @ResponseStatus
are used in a controller method,
the HTTP status from ResponseEntity
takes precedence over the one specified by @ResponseStatus
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final T
private final HttpHeaders
private final HttpStatus
-
Constructor Summary
ConstructorsConstructorDescriptionResponseEntity
(HttpHeaders headers, HttpStatus httpStatus) Constructs a new ResponseEntity with the given headers and HTTP status.ResponseEntity
(T body, HttpHeaders headers, HttpStatus httpStatus) Constructs a new ResponseEntity with the given body, headers, and HTTP status.ResponseEntity
(T body, HttpStatus httpStatus) Constructs a new ResponseEntity with the given body and HTTP status. -
Method Summary
Modifier and TypeMethodDescriptiongetBody()
Gets the body of the response.Gets the headers included in the response.Gets the HTTP status of the response.
-
Field Details
-
headers
-
body
-
httpStatus
-
-
Constructor Details
-
ResponseEntity
Constructs a new ResponseEntity with the given body, headers, and HTTP status.- Parameters:
body
- The response body.headers
- The headers to be included in the response.httpStatus
- The HTTP status of the response.
-
ResponseEntity
Constructs a new ResponseEntity with the given body and HTTP status.- Parameters:
body
- The response body.httpStatus
- The HTTP status of the response.
-
ResponseEntity
Constructs a new ResponseEntity with the given headers and HTTP status.- Parameters:
headers
- The headers to be included in the response.httpStatus
- The HTTP status of the response.
-
-
Method Details
-
getHeaders
Gets the headers included in the response.- Returns:
- The headers of the response.
-
getBody
Gets the body of the response.- Returns:
- The response body.
-
getHttpStatus
Gets the HTTP status of the response.- Returns:
- The HTTP status.
-