I've annotated one of my controllers with @ExceptionHandler
, in hopes of handling the exceptions for that cla开发者_如何转开发ss 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?
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" />
精彩评论