spring boot shiro 权限验证注解报异常不跳转403

来源:互联网 发布:淘宝多久可以追加评论 编辑:程序博客网 时间:2024/06/15 03:52

spring boot shiro 权限验证注解报异常不跳转403


webmvc 配置类添加配置

@Configuration@EnableWebMvc  // Optionally setup Spring MVC defaults (if you aren't using               // Spring Boot & haven't specified @EnableWebMvc elsewhere)public class MvcConfiguration extends WebMvcConfigurerAdapter {  @Bean(name="simpleMappingExceptionResolver")  public SimpleMappingExceptionResolver                  createSimpleMappingExceptionResolver() {    SimpleMappingExceptionResolver r =                new SimpleMappingExceptionResolver();    Properties mappings = new Properties();    mappings.setProperty("DatabaseException", "databaseError");    mappings.setProperty("UnauthorizedException","403");  //捕捉权限异常跳转403页面    r.setExceptionMappings(mappings);  // None by default    r.setDefaultErrorView("error");    // No default    r.setExceptionAttribute("ex");     // Default is "exception" //页面上获取异常信息变量名   // r.setWarnLogCategory("example.MvcLogger");     // No default 日志处理    return r;  }  ...}
参考:https://spring.io/blog/2013/11/01/exception-handling-in-spring-mvc

0 0
原创粉丝点击