Spring SimpleMappingExceptionResolver not going to default view?

As you've discovered SimpleMappingExceptionResolver will not work for exceptions thrown in the view layer. It implements the interface HandlerExceptionResolver which, as the name implies, only handles exceptions thrown by the handler (i.e. The controller) If you need to handle exceptions thrown by the view, you can either write a HandlerInterceptor overriding the afterCompletion() method, or write a non-Spring servlet Filter In both cases, you won't get the benefit of Spring's view resolver, you'll have to handle rendering yourself One word of warning, though - when you get exceptions in the view layer, it's not always possible to handle them gracefully, since the server may have begun to flush the view output to the client when the exception is thrown, in which case the server cannot then render a separate error page.

This is why it's good practice to do as much logic as you can in the controller layer, so that exceptions are caught as early as possible.

As you've discovered, SimpleMappingExceptionResolver will not work for exceptions thrown in the view layer. It implements the interface HandlerExceptionResolver which, as the name implies, only handles exceptions thrown by the handler (i.e. The controller).

If you need to handle exceptions thrown by the view, you can either write a HandlerInterceptor, overriding the afterCompletion() method, or write a non-Spring servlet Filter. In both cases, you won't get the benefit of Spring's view resolver, you'll have to handle rendering yourself. One word of warning, though - when you get exceptions in the view layer, it's not always possible to handle them gracefully, since the server may have begun to flush the view output to the client when the exception is thrown, in which case the server cannot then render a separate error page.

This is why it's good practice to do as much logic as you can in the controller layer, so that exceptions are caught as early as possible.

1 That's really good advice - thank you – Rachel Jun 8 '10 at 10:16.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions