zoukankan      html  css  js  c++  java
  • Shiro_DelegatingFilterProxy

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

    2.配置shiroFilter

    --id必须和web.xml文件中配置的DelegatingFilterProxy的<filter-name>一致。为什么?(看下文)
    --若不一致,则会抛出异常。因为Shiro会来IOC容器寻找与<filter-name>名字对应的filter Bean

    (1)查看org.springframework.web.filter.DelegatingFilterProxy的源码,

    1     /**
    2      * Return the name of the ServletContext attribute which should be used to retrieve the
    3      * {@link WebApplicationContext} from which to load the delegate {@link Filter} bean.
    4      */
    5     public String getContextAttribute() {
    6         return this.contextAttribute;
    7     }
    1     /**
    2      * Set the name of the target bean in the Spring application context.
    3      * The target bean must implement the standard Servlet Filter interface.
    4      * <p>By default, the {@code filter-name} as specified for the
    5      * DelegatingFilterProxy in {@code web.xml} will be used.
    6      */
    7     public void setTargetBeanName(String targetBeanName) {
    8         this.targetBeanName = targetBeanName;
    9     }

    (2)做以下调整,

    web.xml:

    applicationContext.xml:

    结果:可以正常运行。

    每接触一个新领域,我就像一块掉进水里的海绵,四面八方的养分都让我不断充实。O(∩_∩)O~
  • 相关阅读:
    小程序-自定义组件
    51Nod
    CodeForces
    JSON、闭包和原型----透视Javascript语言核心
    转载:动态规划法总结
    to初学者:从汉诺塔问题深入理解递归算法思想
    不知‘时间复杂度’所云的看过来
    盲点流水账记录
    常用序列化协议总结
    排序——了解总体以及插入排序
  • 原文地址:https://www.cnblogs.com/zhzcode/p/9682187.html
Copyright © 2011-2022 走看看