首页 > 解决方案 > 没有为根 URL 运行 Spring 过滤器

问题描述

在 Spring 配置中,我有:

<beans:bean id="myFilter" class="foo.bar.MyFilter" />
<http>
  <custom-filter ref="myFilter" after="CHANNEL_FILTER"/>

我注意到,当使用此 URL 调用根页面时: https://server/myApp 则过滤器不运行,而使用 https://server/myApp/ (唯一的区别是最后的斜杠)运行过滤器. (它也适用于所有子页面,例如 myApp/this 、 myApp/th/at)

启用调试登录org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource我注意到该extractMatchingAttributes()方法甚至没有记录任何内容。

在这两种情况下都会显示正确的网页(运行正确的控制器等)。

这是为什么?

春季版本是 3.0.x

编辑:

该日志给出了提示:

DEBUG o.s.security.web.FilterChainProxy - Candidate is: ''; pattern is /**; matched=false

标签: springspring-mvcspring-securityservlet-filters

解决方案


推荐阅读