Spring Framework filter, bean not injected

前端 未结 1 744
陌清茗
陌清茗 2021-01-02 20:57

There are 2 entries for a Servlet Filter, one in web.xml and one in Spring applicationContext.xml

I added the filter into applicationContext.xml because I wanted to

1条回答
  •  醉话见心
    2021-01-02 21:30

    You can't make a Filter spring managed like this. With your setup it is instantiated once by spring, and once by the servlet container. Instead, use DelegatingFilterProxy:

    1. declare the filter proxy as a in web.xml
    2. Set the targetBeanName init-param of the filter definition to specify the bean that should actually handle the filtering:

      
          targetBeanName
          creditFilter
      
      

    0 讨论(0)
提交回复
热议问题