I am really not sure if this is feasible using Spring 3.2 MVC.
My Controller has a method declared as below:
@RequestMapping(method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public @ResponseBody List<Foo> getAll(){
return service.getAll();
}
Questions:
- What is the meaning of
@ResponseStatus(HttpStatus.OK)
? - Does it signifies that the method will always return a
HttpStatus.OK
status code. - What if an exception is thrown from the service layer?
- Can I change the Response Status on occurrence of any exception?
- How can I handle multiple response statuses depending on conditions in the same method?