shiro权限不生效原因

shiro权限不生效原因

记录一次shiro权限不生效原因。

访问权限配置不能是HashMap,必须使用LinkedHashMap。其实根本原因就是顺序的问题。

	   ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
    //给ShiroFilter配置安全管理器
    shiroFilterFactoryBean.setSecurityManager(securityManager());
    Map<String, Filter> maps=new HashMap<>();
    maps.put("admin", new AdminFilter());
    shiroFilterFactoryBean.setFilters(maps);
    //配置系统受限资源
    //配置系统公共资源
    Map<String, String> map = new LinkedHashMap<>();
    //登出
    map.put("/logout", "logout");
    //对所有用户认证
    map.put("/mlogin", "anon");
    map.put("/index", "anon");
    map.put("/register", "anon");
    map.put("/static/**", "anon");
    map.put("/managesignin", "anon");
    map.put("/admin/login", "anon");
    map.put("/admin/login.html", "anon");
    map.put("/admin/**", "admin");
    // 设置认证界面路径
    //登录
    shiroFilterFactoryBean.setLoginUrl("/admin/login");
    //首页
    shiroFilterFactoryBean.setSuccessUrl("/admin/index");
    //错误页面,认证不通过跳转
    ///demo/src/main/webapp/error.html
    shiroFilterFactoryBean.setUnauthorizedUrl("/error");
    shiroFilterFactoryBean.setFilterChainDefinitionMap(map);
    return shiroFilterFactoryBean;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值