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