Cause: org.apache.shiro.UnavailableSecurityManagerException: No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton. This is an invalid application configuration.
上方报错的几种可能
唯一的原因是在当前的环境中获取的 shiro 的SecurityManager 为空,后面所做的一些列操作便都错误了
1、是spring 的环境中没有把shiro 某些需要的类表示为Bean ,导致Spring无法管理到自然获取不到,这个自己排查。
2、shiro 过滤器对于请求的过滤
查看自己的pavilion文件,是否对于请求进行拦截了,
例如 此时请求为*.do 或是 *.pdf
进入controller 后 可以有对于 securityManager 的相关操作,
若是其他后缀的请求,直接操作securityManager 就会出现上方的错误
添加过滤器 即可解决
<!-- shiro的过滤器 -->
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>*.pdf</url-pattern>
</filter-mapping>