0

我們有一個基於Spring Framework 3.2.x(3.2.12-RELEASE)和Spring Security 3.2.x(即3.2.5-RELEASE)Spring Session和Spring Security(3.2.X RELEASE)

構建的Web應用程序

安全與經典執行彈簧的方法。在web.xml中我們加載的ApplicationContextspringSecurityFilterChain

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> 
<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value> 
     classpath*:META-INF/spring/applicationContext*.xml 
    </param-value> 
</context-param> 
... 
    <filter> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
    </filter> 
    <filter-mapping> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <url-pattern>/*</url-pattern> 
    </filter-mapping> 

如要求改變的,我們試圖探討如何在同一瀏覽器中允許每個選項卡(或窗口)不同的HttpSession:在這種情況下,同一個物理用戶可以使用兩個獨立的應用程序用戶登錄應用程序。

我可以理解,這不可能使用JSESSIONID cookie方法。我正在嘗試使用Spring Session(Spring Session and Spring SecuritySpring Session Multiple Session),但是我無法做到這一點,在將XML配置與之前的鏈接中顯示的JavaConfig方法混合時遇到困難,Tomcat甚至不會以很多錯誤開始。

我是新的混合XML和JavaConfig的接近,所以......任何人都可以給我一個關於如何進行Spring Session的提示嗎?

是否有其他方法可以滿足我的要求?

回答

0

Spring Session項目實際上包含幾個sample projects,它們演示了Spring XML配置的用法。在示例名稱中查找帶有-xml後綴的示例。

一般而言,您需要做的是手動將相應的@Configuration類註冊爲@Bean。例如,如果您想使用Redis支持的Spring Session,請註冊RedisHttpSessionConfiguration。通過查看適當的@Enable*HttpSession註釋(在這種情況下爲@EnableRedisHttpSession)並通過@Import註釋確定導入哪個類,您將找到正確的@Configuration類。

相關問題