在配置类里加上一个bean
@Bean
public SimpleMappingExceptionResolver simpleMappingExceptionResolver() {
SimpleMappingExceptionResolver exceptionResolver = new SimpleMappingExceptionResolver();
Properties properties = new Properties();
// 配置上未授权的跳转页面
properties.put("org.apache.shiro.authz.UnauthorizedException", unauthorizedUrl);
exceptionResolver.setExceptionMappings(properties);
return exceptionResolver;
}