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();
      }
JOGO
  • 285
  • 2
  • 7
  • 16
  • Could you please let me know what your get method is returning in response?? – cody123 Jan 28 '16 at 07:05
  • Short answer, return the correct type (ResponseEntity). Read the answer referenced in the fabriziomieli answer. – DwB Jan 28 '16 at 07:31

1 Answers1

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

Community
  • 1
  • 1
fabriziomieli
  • 141
  • 1
  • 1
  • 9