Reputation: 5314
Here's what i have so far : controller :
public abstract class MyController {
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public void handleAllExceptions(Exception e) {
// stuff
}
}
and my web.xml :
<error-page>
<error-code>500</error-code>
<location>/error.htm</location>
</error-page>
And when an unexpected exception occur, the handle works, the stuff is done, but i'm not redirect to /error.htm
Instead i'm still on the same page, but a error 500 is printed by apache.
What did i miss ?
Thanks :)
Upvotes: 1
Views: 2013
Reputation: 120871
I think you need to return the view you want to show.
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public String handleAllExceptions(Exception e) {
return "error.jsp"; /* use the correct view name */
}
@see: Spring 3 controller exception handler implementation problems for some examples
Upvotes: 3