I wonder what the difference is between the return value of a Spring Boot RestController if void shall be returned?
I can see do difference in a test in either way. It seems that even if I return void the HttpStatus.NO_CONTENT
(204) is returned to the requester as well as if I use ResponseEntity<Void>
.
So, when I return void
from an endpoint the HttpStatus is returned anyway and it doesn't matter if I choose void
or ResponseEntity<Void>
?
CodePudding user response:
Exactly. You would need the ResponseEntity<Void>
if you want to add some headers.