0

I am trying to get the list of data as list. But i need to return http status 404 if server is unreachable. for me POST method is working fine , but GET method returns 200 with http.ok to client page. how to add response ?

 @RequestMapping(value = "/config/filedata/data", method = RequestMethod.GET) @ResponseBody public List<filedata> getAllFileDatas() { return filedataServices.getAllFileDatas(); } 
2
  • Could you please let me know what your get method is returning in response?? Commented Jan 28, 2016 at 7:05
  • Short answer, return the correct type (ResponseEntity). Read the answer referenced in the fabriziomieli answer. Commented Jan 28, 2016 at 7:31

1 Answer 1

1


Have a look at this link, it should answer your question.
How to respond with HTTP 400 error in a Spring MVC @ResponseBody method returning String?
In any case, http error code 404 is returned when server is unreachable, so usually it's not a code returned programmatively.

https://en.wikipedia.org/wiki/HTTP_404

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.