gpt4 book ai didi

spring - 覆盖 spring @ExceptionHandler 方法

转载 作者:行者123 更新时间:2023-12-05 01:30:56 26 4
gpt4 key购买 nike

如果我有一个带有两个单独方法的 Spring Controller ,一个注释为:

@ExceptionHandler(Exception.class)

另一个注释为:
@ExceptionHandler(SubException.class)

我的 Controller 抛出 SubException.class ,它是由这两种方法处理的,还是只是 @ExceptionHandler(SubException.class) ?

最佳答案

将在最合适的基础上调用一个处理程序。

确切的实现在 AnnotationMethodHandlerExceptionResolver.findBestExceptionHandlerMethod(Object,Exception)

关于spring - 覆盖 spring @ExceptionHandler 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9819998/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com