解决方案:
对抛出的异常进行统一处理:(新建类)
package com.example.demo.exceptions;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
/**
* Created by qwe on 2019/8/2.
*/
@ControllerAdvice
public class NoPermissionException {
@ExceptionHandler(UnauthorizedException.class)
public String handleShiroException(Exception ex) {
return "403";
}
}
原理请看原创:
shiro无权限,不跳转到指定页面。setUnauthorizedUrl无效_我是你妹她哥的博客-优快云博客_shiro 不跳转