I have a Spring MVC Rest controller with one of the URL mappings being :
myhost:8080/helloworldexample/testnullresponse
Now, is it possible to return nothing at all when I call this URL
Nothing means: no body, no response, no status code simply nothing at all, almost like the server listening to the request did not do anything.
I would appreciate any help on this. I have tried the following options but nothing worked:
return new ResponseEntity<Void>(null);
@RequestMapping(value = "/helloworldexample/testnullresponse", produces = "application/json; charset=UTF-8", method = RequestMethod.GET)
public void nullResponse(HttpServletRequest request) {
}
Actually your controller's method could return void. Here is an example
@RequestMapping(value = "/helloworldexample/testnullresponse", method = RequestMethod.HEAD)
public void nullResponse(HttpServletResponse response) {
...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.