Spring3 @ExceptionHandler for ServletRequestBindingException

前端 未结 4 1434
醉话见心
醉话见心 2020-12-11 08:10

I am using a Default AnnotationMethodHandlerAdapter which I believe should enable support for @ExceptionHandler. Unluckily, a ServletRequestBindingException is thrown if a c

4条回答
  •  我在风中等你
    2020-12-11 08:40

    Unfortunately, @ExceptionHandler methods are only invoked for exceptions that are thrown from within the handler method. ServletRequestBindingException is an infrastructure exception that is thrown whilst trying to invoke a handler method, and if the handler method itself cannot be invoked for whatever reason, then the @ExceptionHandler is not used.

    There doesn't really seem to be a nicer way to handle this. Without knowing what's causing your ServletRequestBindingException, though, it's hard to advise.

提交回复
热议问题