• shiro中anon配置不生效


    再配置shiro的时候,如下代码要注意:

    1、下述代码中必须是LinkedHashMap 而不能是HashMap。

    2、anon定义必须在authc之前

    否则anon定义不生效

      @Bean
            public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager){
                ShiroFilterFactoryBean factoryBean = new ShiroFilterFactoryBean();
                factoryBean.setSecurityManager(securityManager);
    
    //            设置登录跳转
                factoryBean.setLoginUrl("/admin");
                factoryBean.setSuccessUrl("/admin/index");
    
                //必须为LinkedHashMap 否则anon不生效
                Map<String,String> map = new LinkedHashMap<>();
    
                //退出
                map.put("/admin/logout","logout");
    
                //登录页面和登录验证不要拦截
                map.put("/admin/login.html","anon");
                map.put("/admin/tologin","anon");
    
                //设置需要过滤的链接
                map.put("/admin/**","authc");
    
    
    
                factoryBean.setFilterChainDefinitionMap(map);
    
                return factoryBean;
            }
  • 相关阅读:
    1058 A+B in Hogwarts (20)
    1046 Shortest Distance (20)
    1061 Dating (20)
    1041 Be Unique (20)
    1015 Reversible Primes (20)(20 分)
    pat 1027 Colors in Mars (20)
    PAT 1008 Elevator (20)
    操作系统 死锁
    Ajax的get方式传值 避免& 与= 号
    让IE浏览器支持CSS3表现
  • 原文地址:https://www.cnblogs.com/shyroke/p/10138705.html
Copyright © 2020-2023  润新知