title: Programmatically change http response status using spring 3 restful
body: <p>I have a controller like below</p>
  
  <pre><code>@Controller("myController")
  @RequestMapping("api")
  public class MyController {
  
       @RequestMapping(method = RequestMethod.GET, value = "/get/info/{id}", headers = "Accept=application/json")
      public @ResponseBody
      Student getInfo(@PathVariable String info) {
  .................
  }
  
  
  
  
      @ExceptionHandler(Throwable.class)
      @ResponseStatus( HttpStatus.EXPECTATION_FAILED)
      @ResponseBody
      public String handleIOException(Throwable ex) {
          ErrorResponse errorResponse = errorHandler.handelErrorResponse(ex);
          return errorResponse.toString();
      }
  
  }
  </code></pre>
  
  <p>The controller has an error handling mechanism, in the error handling option it always return expectation fail status code 417. But I need to set a dynamic error Http status code like 500, 403 etc depending on type of error. How do I do this?</p>