Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

427
Views
What's the difference between ResponseEntity and HttpEntity in Spring?

What's the difference between ResponseEntity and HttpEntity in Spring? I want to know the difference between the two and when to use them in a Spring MVC controller.

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

HttpEntity can be used to create both RequestEntity and ResponseEntity.

Where as ResponseEntity is subclassed from HttpEntity with a more elaborative way to send the ResponseObject and it only limited to sending the Response. Some Key differences are below :

  1. ResponseEntity inherited from HttpEntity that has an additional HttpStatus Code while Sending the ResponseEntity Object.

  2. Also it has ResponseEntity.BodyBuilder which adds body to the response Object and ResponseEntity.HeadersBuilder which adds header to the Response object.

about 4 years ago · Santiago Trujillo Report

0

An HTTP entity is the majority of an HTTP request or response, consisting of some of the headers and the body, if present. It seems to be the entire request or response without the request or status line (although only certain header fields are considered part of the entity).

while ResponseEntity is meant to represent the entire HTTP response. You can control anything that goes into it: status code, headers, and body.

about 4 years ago · Santiago Trujillo Report

0

HttpEntity wraps both the request and response message. But the ResponseEntity wraps only the response message. ResponseEntity basically inherits from HttpEntity. Response Entity can also have a HTTP status code unlike its parent class. ex:

new ResponseEntity<String>("Hello World", responseHeaders, HttpStatus.CREATED);

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!