- shiroConfig配置中增加了如下代码,就能跳转到403页面了:
@Bean(name = "simpleMappingExceptionResolver")
public SimpleMappingExceptionResolver simpleMappingExceptionResolver() {
SimpleMappingExceptionResolver simpleMappingExceptionResolver = new SimpleMappingExceptionResolver();
Properties mappings = new Properties();
mappings.setProperty("DatabaseException", "databaseError"); // 数据库异常
mappings.setProperty("UnauthorizedException", "error/403"); // 页面地址
simpleMappingExceptionResolver.setExceptionMappings(mappings);
simpleMappingExceptionResolver.setDefaultErrorView("error/404");
simpleMappingExceptionResolver.setExceptionAttribute("exception");
return simpleMappingExceptionResolver;
}
![](https://i-blog.csdnimg.cn/blog_migrate/ac9c930e0e05fe123729e075eea6dc96.png)