2013-03-21 52 views
-1

我已經在SpringSource Tool Suite中啓動了一個Spring應用程序,我想在我的Web應用程序中添加一個會話管理功能,那就是我想阻止用戶使用同一個帳戶登錄。Spring會話併發教程

我搜索了網上的教程和指南,但沒有找到一個直觀的我在春天的知識。有人可以給我一個「初學者教程」文章。

+0

什麼是「會話併發」? – 2013-03-21 03:19:32

+0

我想阻止用戶使用相同的帳戶登錄。更像會話管理。對困惑感到抱歉。 – Oneb 2013-03-21 03:21:08

回答

2

Spring Security按照here的描述提供了這個功能。

典型的Maven依賴使用的是:

<dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-web</artifactId> 
     <version>3.1.3</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-taglibs</artifactId> 
     <version>3.1.3</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-config</artifactId> 
     <version>3.1.3</version> 
    </dependency> 

在XML配置,報關通常是這樣的:

<?xml version="1.0" encoding="UTF-8"?> 
<beans 
    xmlns="http://www.springframework.org/schema/beans" 
    xmlns:sec="http://www.springframework.org/schema/security" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
     http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> 

然後你就可以用諸如

sec:前綴的安全要素
<sec:custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrencyFilter" /> 

或者如果你離開的例子從我鏈接到的Spring Security文檔中,它爲bean名稱空間加上前綴,並將安全性作爲默認值。無論哪種方式都應該達到同樣的目的。

+0

我會給這個鏡頭。你有春天安全的maven依賴鏈接嗎? – Oneb 2013-03-21 03:32:04

+0

我有關於xml中的http命名空間的錯誤。任何想法我怎麼能解決這個問題?我一直在尋找正確的命名空間,但仍然不吉利。 – Oneb 2013-03-21 05:54:13

+0

@Oneb你錯過了Spring Security庫嗎? – huahsin68 2013-06-22 14:29:04