No SecurityManager accessible to the calling code 错误解决方式

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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值