David Parks
David Parks

Reputation: 32081

Spring Exception handlers - using both annotated and xml defined

I've annotated one of my controllers with @ExceptionHandler, in hopes of handling the exceptions for that class within the following method.

We also have a site-wide exception handler defined in XML (SimpleMappingExceptionResolver).

The SimpleMappingExceptionResolver is still handling exceptions in my controller with an @ExceptionHandler annotation.

How can I get the controller specific exception handler to deal with exceptions coming from its controller?

Upvotes: 1

Views: 1100

Answers (1)

David Parks
David Parks

Reputation: 32081

Answered in tremendous depth and clarity here:

Basically it says to add the AnnotationMethodHandlerExceptionResolver manually (adding SimpleMappingExceptionResolver causes the Annotation resolver not to be automatically added), and set the order of the two Resolvers.

<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver" 
      p:order="1" />

Upvotes: 2

Related Questions