目前Spring官方只提供Meven的下載方式。但在[http://maven.springframework.org](http://maven.springframework.org/)中有SpringSecurity及其他所有Spring產品的下載方式。
[http://maven.springframework.org/release/org/springframework/](http://maven.springframework.org/release/org/springframework/)中有Spring相關的所有下載,但好像直到3.2版的,最新的版本在這個里面找不到
[](http://maven.springframework.org/release/org/springframework/security/spring-security-web/3.2.0.RELEASE/)[http://maven.springframework.org/release/org/springframework/security/spring-security/3.2.0.RELEASE/](http://maven.springframework.org/release/org/springframework/security/spring-security/3.2.0.RELEASE/)這個是SpringSecurity3.2的下載地址
Meven下載地址:
~~~
<dependencies>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
</dependencies>
~~~
本教程是基于SpringMVC3.2+Hibernate4+JPA2.0+SpringSecurity3.2的環境。SpringMVC3.2+Hibernate4+JPA2.0環境的搭建在這里就不多說了,主要講下SpringSecurity的環境搭建
web.xml配置
~~~
<!-- 加載Spring的配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext.xml,
classpath:applicationContext-security.xml
</param-value>
</context-param>
<!-- SpringSecurity 核心過濾器配置 -->
<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>
~~~
applicationContext-security.xml命名空間配置,官方提供了兩種配置方案
第一種、命名空間用beans開頭,但是在配置中一直需要用<security:*>來配置。
~~~
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:security="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.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
...
</beans>
~~~
第二種、命名空間用security開頭,在配置中不需要security前綴,但是bean的配置需要用<beans:bean>配置。
~~~
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
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.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
...
</beans:beans>
~~~
到此為止SpringSecurity的環境配置已基本完成
命名空間的配置可在spring的官方文檔,第4章?Security Namespace Configuration 中找到,一下附上鏈接地址
[http://docs.spring.io/spring-security/site/docs/3.2.0.RELEASE/reference/htmlsingle/#ns-config](http://docs.spring.io/spring-security/site/docs/3.2.0.RELEASE/reference/htmlsingle/#ns-config)
- 前言
- (大綱)----學習過程分享
- (1)----SpringSecurity3.2環境搭建
- (2)----SpringSecurity簡單測試
- (3)---- 自定義登錄頁面
- (4)---- 數據庫表結構的創建
- (5)---- 國際化配置及UserCache
- (6)---- 使用數據庫管理用戶及權限
- (7)---- 解決UsernameNotFoundException無法被捕獲的問題
- (8)---- 自定義決策管理器及修改權限前綴
- (9)---- 自定義AccessDeniedHandler
- (10)---- 自定義登錄成功后的處理程序及修改默認驗證地址
- (11)---- 使用數據庫來管理資源
- (12)---- 使用數據庫來管理方法
- (13)---- 驗證碼功能的實現
- (14)---- Logout和SessionManager