Shiro抛出异常UnavailableSecurityManagerException

Shiro报错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.
解决方法,修改web.xml的filter,将<url-pattern>/</url-pattern>改成<url-pattern>/*</url-pattern>,即:

1
2
3
4
5
6
7
8
9
<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>/</url-pattern>
</filter-mapping>