title: Spring MVC: using @ResponseStatus(reason = '') on a @ResponseBody exception handler in tomcat
body: <p>Does anybody know why I cannot use <code>@ResponseStatus(reason = "My message")</code> on an exception handler in spring MVC while still returning a @ResponseBody. What seems to happen is that if I use the <code>reason</code> attribute</p>
  
  <pre><code>// 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&lt;String, String&gt; 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&lt;String, String&gt; reallyNotFoundHandler(ReallyNotFoundException e){
      return Collections.singletonMap("message", e.getMessage());
  }
  </code></pre>
  
  <p>The <a href="https://github.com/gid79/spring-mvc-json-error-resolver" rel="noreferrer">code for this example</a> is over on github.</p>