Monday, 30 July 2012

Actions throwing exceptions in Spring MVC

When an action in the Spring MVC throws exception, you can handle it with specifying http response code, by annotation on the exception class definition: @ResponseStatus(httpStatus).
When you cannot annotate class, f.e. it is not your exception definition, you can add in the controller a method which is annotated with @ExceptionHandler(yourExceptionClass) and @ResponseStatus(httpStatus)

No comments: