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:

 

结果:可以正常运行。

 

转载于:https://www.cnblogs.com/zhzcode/p/9682187.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值