SpringBoot自带异常拦截@ControllerAdvice
1.创建一个SellerExceptionHandler类打上@ControllerAdvice标签
@ControllerAdvice public class SellExceptionHandler { }
2.创建异常处理程序@ExceptionHandler(value = SellerAuthorizeException.class)表示拦截的异常为SellerAuthorizeException异常
/** * 拦截登录异常 * @return */ @ExceptionHandler(value = SellerAuthorizeException.class) public ModelAndView handlerAuthorizeException(){ return new ModelAndView("redirect:" + projectUrlConfig.getSell() + "/sell/seller/toLogin"); }
原文:https://www.cnblogs.com/xzmxddx/p/10330845.html