DelegatingFilterProx

Spring DelegatingFilterProxy 源码分析

折月煮酒 提交于 2020-03-02 18:23:55
在web项目,利用Spirng 管理权限框架时,不管权限框架使用的是Shiro还是SpringSecucrity在web.xml文件中都有一个名org.springframework.web.filter.DelegatingFilterProxy 的Filter。 配置如下: <filter> <filter-name>securityFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> DelegatingFilterProxy 是Spring web内部一个类,其实现了GenericFilterBean,而GenericFilterBean又实现了javax.servlet.Filter接口,并对Filter#init方法进行了重写,而Filter#doFilter交给其子类去实现。而GenericFilterBean#init方法内部调用了GenericFilterBean

Spring与Shiro整合源码分析

拈花ヽ惹草 提交于 2020-03-02 16:38:45
Spring与Shiro整合是通过在web.xml里面配置过滤器: <filter> <filter-name>shiroFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <init-param> <param-name>targetFileterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>shiroFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> <dispatcher>ERROR</dispatcher> </filter-mapping> 然后我们在apllicationContext.xml里面配置如下的ShiroFilterFactoryBean就可以了 <!-- Shiro 的Web过滤器 -->