Spring @ExceptionHandler handling multiple kinds of exceptions

后端 未结 3 1250
暖寄归人
暖寄归人 2021-02-03 22:18

I can\'t figure out how to handle more than one kind of exception by @ExceptionHandler.

I need to programmatically deal with these exceptions, for this I\'d need a shar

3条回答
  •  借酒劲吻你
    2021-02-03 22:38

    The @ExceptionHandler value can be set to an array of Exception types.

    The implementation of using exception array as mentioned in Spring documentation will be like:

    @ExceptionHandler({
        NotFoundException.class,
        MissingServletRequestParameterException.class
     })
    

提交回复
热议问题