Return ResponseEntity vs returning POJO

Returning the ResponseEntity gives you more control over how the HTTP Response is generated, especially when it comes to HTTP status codes and other headers.

You could easily create a response with HttpStatus.CREATED or an specific error code to tailor your API.

If you are OK with a HTTP 200 and a serialized version of your POJO, simply returning the POJO is fine.

If you want more control when designing your API, use ResponseEntity.


ResponseEntity<T> represents the entire HTTP response. Besides the body, its API allows you to set headers and a status code to the response.

Returning just a bean is fine but doesn't give you much flexibility: In the future, if you need to add a header to the response or modify the status code, for example, you need to change the method return type.

For more details on return values, refer to the Spring MVC documentation.