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的源码,

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

(2)做以下调整,

web.xml:

applicationContext.xml:

结果:可以正常运行。

Shiro_DelegatingFilterProxy的更多相关文章

  1. 配置ShiroFilter需要注意的问题(Shiro_DelegatingFilterProxy)

    ShiroFilter的工作原理 ShiroFilter:DelegatingFilterProxy作用是自动到Spring 容器查找名字为shiroFilter(filter-name)的bean并 ...

随机推荐

  1. http报文和协议首部

    http报文和协议首部 http报文 3>报文格式 request 报文 <method> <request-URL> <version> <heade ...

  2. spring cloud config搭建说明例子(三)-添加actuator

    添加心跳 服务端 ConfigServer pom.xml添加actuator包 <dependency> <groupId>org.springframework.cloud ...

  3. redis的两种备份方式

    Redis提供了两种持久化选项,分别是RDB和AOF. 默认情况下60秒刷新到disk一次[save 60 10000 当有1w条keys数据被改变时],Redis的数据集保存在叫dump.rdb一个 ...

  4. 'latin-1' codec can't encode characters in position解决字符问题

    当遇到这样的报错时,原因是: pymysql库在处理mysql语句时,默认的编码方式是'latin-1',这种编码方式能识别的字符是有限的 解决办法:找到\site-packages\pymysql\ ...

  5. [SHOI2013]超级跳马

    题目描述 现有一个n 行m 列的棋盘,一只马欲从棋盘的左上角跳到右下角.每一步它向右跳奇数列,且跳到本行或相邻行.跳越期间,马不能离开棋盘.试求跳法种数mod 30011. 输入输出格式 输入格式: ...

  6. 二分搜索 HDOJ 2289 Cup

    题目传送门 /* 二分搜索:枚举高度,计算体积与给出的比较. */ #include <cstdio> #include <algorithm> #include <cs ...

  7. [译]libcurl_tutorial

    Handle the Easy libcurl To use the easy interface, you must first create yourself an easy handle. Yo ...

  8. php函数的定义和声明

    1.函数的定义 函数是一个被命名的独立的代码段,它执行特定任务,并可以给调用它的程序返回值. 2.函数的优点 提高程序的重用性 提高程序的可维护性 可以提高软件的开发效率 提高软件的可靠性 控制程序的 ...

  9. pom.xml详情

    这里借鉴一下csdn中的一个系列的博客: 第一篇:POM文件详解 第二篇:maven中的依赖作用范围 第三篇:maven中的可选依赖和依赖排除 第四篇:maven中的dependencies和depe ...

  10. Javascript的一些技巧(《Javascript DOM编程艺术》、Javascript语言精粹)

    1.什么时候用布尔变量当变量 假设你需要一个这样的变量:我在睡觉——存为一个值:我没在睡觉——存为另一个值. 一般的做法: var stateOne="睡觉",stateTwo=& ...