zl程序教程

您现在的位置是:首页 >  其他

当前栏目

DelegatingFilterProxy 配置

2023-04-18 14:39:46 时间

DelegatingFilterProxy 的filter-name对应的bean默认只能在applicationContext.xml中建立,如果想把filter-name这个bean配置到mvc的配置文件中,可以在web.xml中这么配置。

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    <init-param>
        <param-name>contextAttribute</param-name>
        <param-value>org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring-mvc</param-value>
    </init-param>
</filter>

spring-mvc是DispatcherServlet在web.xml中配置的servlet-name。