में एक @ResponseBody अपवाद संचालक पर @ResponseStatus का उपयोग कर किसी को भी पता है कि मैं क्यों वसंत MVC में अपवाद संचालक पर @ResponseStatus(reason = "My message")
उपयोग नहीं कर सकते, जबकि अभी भी एक @ResponseBody लौटने। क्या लगता है कि अगर मैं reason
विशेषता का उपयोगवसंत MVC: (कारण = '') बिल्ला
// this exception handle works, the result is a 404 and the http body is the json serialised
// {"message", "the message"}
@ExceptionHandler
@ResponseStatus(value = HttpStatus.NOT_FOUND)
public Map<String, String> notFoundHandler(NotFoundException e){
return Collections.singletonMap("message", e.getMessage());
}
// this doesn't... the response is a 404 and the status line reads 'Really really not found'
// but the body is actually the standard Tomcat 404 page
@ExceptionHandler
@ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Really really not found")
public Map<String, String> reallyNotFoundHandler(ReallyNotFoundException e){
return Collections.singletonMap("message", e.getMessage());
}
code for this example GitHub पर खत्म हो गया है है।
वही समस्या यहां: http://stackoverflow.com/questions/ 29075160/no-responsebody-लौटे-से-exceptionhandler में वसंत-बूट, एप्लिकेशन के तहत तैनात-इन –