Shiro的ShiroFilterFactoryBean在设置ChainDefinitionMap最多12条的限制如何破?

Published on in 后端 with 7,881 views and 2 comments

先上代码:

ShiroFilterFactoryBean  shiroFilterFactoryBean = new  ShiroFilterFactoryBean();

shiroFilterFactoryBean.setSecurityManager(securityManager);

shiroFilterFactoryBean.setLoginUrl("/login/login");
shiroFilterFactoryBean.setSuccessUrl("/index");
shiroFilterFactoryBean.setUnauthorizedUrl("/403");

Map<String, String> filterChainDefinitionMap = new  HashMap<String, String>();
filterChainDefinitionMap.put("/favicon.ico", "anon");
filterChainDefinitionMap.put("/css/**", "anon");
filterChainDefinitionMap.put("/js/**", "anon");
filterChainDefinitionMap.put("/lib/**", "anon");
filterChainDefinitionMap.put("/mock/**", "anon");
filterChainDefinitionMap.put("/images/**", "anon");
filterChainDefinitionMap.put("/captcha/**", "anon");
filterChainDefinitionMap.put("/login/**", "anon");
filterChainDefinitionMap.put("/register/**", "anon");
filterChainDefinitionMap.put("/plugin/**" , "anon");
filterChainDefinitionMap.put("/logout", "logout");
filterChainDefinitionMap.put("/**", "authc");
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
return  shiroFilterFactoryBean;

在filterChainDefinitionMap下面最多可以配置12条验证规则,如果我再添加一条就会出问题,比如images下的图片也将会被要求验证才能访问。

现在请问下这种情况有没有什么办法可以解决?

Responses
  • 问题已经解决,HashMap改为LinkedHashMap即可,和集合个数无关

    Reply
  • 您好,这个问题我也遇到了,您后面有解决方案了吗,能不能配置12个以上呢,帮忙解答下,谢谢了

    Reply