注册Bean
SimpleMappingExceptionResolver
设置异常对应的url,url需要在Controller中指定
@Bean
public SimpleMappingExceptionResolver simpleMappingExceptionResolver() {
SimpleMappingExceptionResolver resolver = new SimpleMappingExceptionResolver();
Properties properties = new Properties();
/*未授权处理页*/
properties.setProperty("org.apache.shiro.authz.UnauthorizedException", "/unauthor");
/*身份没有验证*/
properties.setProperty("org.apache.shiro.authz.UnauthenticatedException", "/login.html");
resolver.setExceptionMappings(properties);
return resolver;
}