Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ResponseEntity Spring MVC

I want to use the ResponseEntity without returning a body, only set status code and headers. The ResponseEntity is a generic class, do I need to specify the type in this case, and if, what should it be?

like image 805
LuckyLuke Avatar asked Jun 18 '26 15:06

LuckyLuke


2 Answers

No you don't, just do something like this

ResponseEntity responseEntity  = new ResponseEntity(HttpStatus.BAD_REQUEST);
like image 104
NimChimpsky Avatar answered Jun 21 '26 04:06

NimChimpsky


You can use return ResponseEntity<Void>

like image 32
Jukka Avatar answered Jun 21 '26 06:06

Jukka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!