2
我们正试图将传统项目转换为更现代的项目。这是一个基于servlet的应用程序,我们正朝着Spring方向发展。我们服务于jsp-s,它们包含许多静态资源。 我们使用Redis的作为会话存储,它的映射就像一个过滤器:如何从springSessionRepositoryFilter中排除资源?
<filter>
<filter-name>springSessionRepositoryFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSessionRepositoryFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
...
@Configuration
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = SpringSessionConfig.MAX_INACTIVE_INTERVAL_IN_SECONDS)
@PropertySource(value = "classpath:redis.properties")
public class SpringSessionConfig { ... }
静态资源被用在许多不同的目录传播,问题是,这种过滤器运行每一个资源,这是完全可以理解的。
有没有一种聪明的方法来从这个url模式中排除资源?或者这个RepositoryFilter的一些配置?
我想出的唯一解决方案是做一个大的重构,并为静态资源创建适当的命名空间,但现在,这太费工夫了。
我还为Spring配置添加了资源处理程序,但在此处将其忽略。
谢谢,我也会检查一下。现在我正在尝试与FilterChainProxy类似的东西。在这里找到:https://github.com/spring-projects/spring-session/issues/278 – JSONStatham
是的,你也可以这样做,把过滤器放在过滤链中。然后使用弹簧安全请求匹配 – chaoluo