写一个配置类如下
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;
import java.util.Properties;
@Configuration
public class ExceptionConf {
@Bean
public SimpleMappingExceptionResolver resolver() {
SimpleMappingExceptionResolver resolver = new SimpleMappingExceptionResolver();
Properties properties = new Properties();
//后面加上你的处理页面即可
properties.setProperty("org.apache.shiro.authz.UnauthorizedException", "/notRole");
resolver.setExceptionMappings(properties);
return resolver;
}
}