问题描述
我无法使 @ControllerAdvice
正常工作。我更新了我的命名空间位置,这在我的xml文件中是3.1。我将控制器的类移动到与控制器相同的包中。我正在使用3.2.0版本的jar。如果我将 @ExceptionHandler
注释放在控制器代码中,它可以工作,但不能在一个单独的类中使用 @ControllerAdvice
。当 @ControllerAdvice
类失败时,我会收到我未捕获的异常处理程序视图。任何人有如何解决这个问题的想法?
I am having trouble getting @ControllerAdvice
to work. I updated my namespace location, which were 3.1 in my xml files. I moved the class with the controller to the same package as the controller. I am using 3.2.0 release jars. If I put the @ExceptionHandler
annotation in the controller code, it works, but not in a separate class with the @ControllerAdvice
. When the @ControllerAdvice
class fails, I get my uncaught exception handler view. Anyone have ideas on how to trouble shoot this one?
推荐答案
没有额外的配置需要。它应该只是工作看这个链接了解更多细节。这提供了非常简单的例子:
There is no extra configuration required. It should just work. Look at this link for more details. This provide very simple example:
这篇关于Spring 3.2 @ControllerAdvice不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!