标签:value 标签 项目 boot ice mod handler style 创建
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"); }
标签:value 标签 项目 boot ice mod handler style 创建
原文地址:https://www.cnblogs.com/xzmxddx/p/10330845.html