一、shiro通过过滤器来拦截所有请求
这个过滤器是spring的委托过滤器,真正的过滤器是在spring容器中配置的shiro类。因为org.springframework.web.filter.DelegatingFilterProxy这个过滤器是也是spring的,也是在spring容器中,所以spring可以把spring容器中的shiro类装配到这个类的属性上,spring默认是使用中的名字作为id去spring容器中bean。所以spring容器中配置这个由shiro类的时候bean的id也必须和中的一样都是shiroFilter
WEB.中的配置:
Spring配置文件applicationContext.xml中的配置:
二、用户登录认证
所谓的用户登陆认证就是在realm中的doGetAuthenticationInfo()方法,根据usernamepasswordtoken 中的username去数据库里查询用户,如果查不到返回null就可以自己编码抛个异常出来如AuthenticationException 。如果查到了,就将用户名、从数据库查到的密码、盐等信息设置到SimpleAuthenticationInfo返回。
new SimpleAuthenticationInfo(