DelegatingFilterProxy管理过滤器
DelegatingFilterProxy提供了在 web.xml和application context之间的联系
FilterChainProxy过滤器链
这是一种繁琐的方式,会让web.xml显得十分杂乱,如果我们配置了太多过滤器的话。 我们最好添加一个单独的入口,在web.xml中,然后在application context中处理实体, 管理我们的web安全bean。 这就是FilterChainProxy所做的事情。
web.xml配置
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/character-context.xml
/WEB-INF/spring-configuration/*.xml
/WEB-INF/deployerConfigContext.xml
classpath*:/META-INF/spring/*.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<filter>
<filter-name>DelegatingFilterProxy</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetBeanName</param-name>
<param-value>myFilter</param-value>
</init-param>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>DelegatingFilterProxy</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
character-context.xml配置
<bean id="cpc" class="com.chinamobile.cmss.sso.web.filter.CustomizedPropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/WEB-INF/cas.properties</value>
</list>
</property>
<property name="fileEncoding" value="utf-8" />
</bean>
<bean id="myFilter" class="com.chinamobile.cmss.sso.web.filter.CrossDomainFilter"> 原始的过滤器,继承Filter
<property name="cpc">
<ref bean="cpc"/>
</property>
</bean>