4.Shiro_DelegatingFilterProxy

web.xml中class="DelegatingFilterProxy"中filtername标签值,与application.xml中class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"中bean id必须一致

若不一致, 则会抛出: NoSuchBeanDefinitionException. 因为 Shiro 会来IOC 容器中查找和 <filter-name> 名字对应的 filter bean.

web.xml中,DelegatingFilterProxy 实际上是 Filter 的一个代理对象. 默认情况下, Spring 会到 IOC 容器中查找和 <filter-name> 对应的 filter bean. 也可以通过 targetBeanName 的初始化参数来配置 filter bean 的 id. 

修改targetBeanName的初始化参数:  

<filter>

        <filter-name>shiroFilter</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>
        <init-param>
        <param-name>targetBeanName</param-name>
        <param-value>ABC</param-value>
        </init-param>

    </filter>

对应的ShiroFilterFactoryBean的id也需修改成ABC,项目才不会报错。





























猜你喜欢

转载自blog.csdn.net/weixin_36439837/article/details/80312269
今日推荐