开发者

Spring: SimpleMappingExceptionResolver together with @ExceptionHandler?

I like SimpleMappingExceptionResolver, because in one place i have all exception->view mappings for all controllers in web-app (i suppose that). To customize some exception in specific controller i would like to use @ExceptionHandler, but it doesn't work together - all exceptions are handled by SimpleMappingExceptionResolver. How to make this work together ?

@Controller
public class SomeController {
    ...

    @ExceptionHandler(SomeException.class)
    public ModelAndView handleException(Exception ex) {
         // ...
    }   

}

SimpleMappingExceptionResolver:

<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
    &开发者_如何学Golt;property name="defaultErrorView" value="error"/>
    <property name="exceptionMappings">
        ...
    </property>
</bean> 


Short answer: p:order

<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver" p:order="1" />
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver" p:order="2" p:defaultErrorView="uncaughtException"/>

Full story: springsource forum.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜