原文地址:http://blog.csdn.net/jaune161/article/details/17640071

http://blog.csdn.net/jaune161/article/details/18736687

spring-security官网网址:http://docs.spring.io/spring-security/site/docs/3.2.0.RELEASE/reference/htmlsingle/#ns-config

目前Spring官方只提供Meven的下载方式。但在http://maven.springframework.org中有SpringSecurity及其他所有Spring产品的下载方式。

http://maven.springframework.org/release/org/springframework/中有Spring相关的所有下载,但好像直到3.2版的,最新的版本在这个里面找不到

http://maven.springframework.org/release/org/springframework/security/spring-security/3.2.0.RELEASE/这个是SpringSecurity3.2的下载地址

Meven下载地址:

  1. <dependencies>
  2. <dependency>
  3. <groupId>org.springframework.security</groupId>
  4. <artifactId>spring-security-web</artifactId>
  5. <version>3.2.0.RELEASE</version>
  6. </dependency>
  7. <dependency>
  8. <groupId>org.springframework.security</groupId>
  9. <artifactId>spring-security-config</artifactId>
  10. <version>3.2.0.RELEASE</version>
  11. </dependency>
  12. </dependencies>

本教程是基于SpringMVC3.2+Hibernate4+JPA2.0+SpringSecurity3.2的环境。SpringMVC3.2+Hibernate4+JPA2.0环境的搭建在这里就不多说了,主要讲下SpringSecurity的环境搭建

web.xml配置

  1. <!-- 加载Spring的配置文件 -->
  2. <context-param>
  3. <param-name>contextConfigLocation</param-name>
  4. <param-value>
  5. classpath:applicationContext.xml,
  6. classpath:applicationContext-security.xml
  7. </param-value>
  8. </context-param>
  9. <!-- SpringSecurity 核心过滤器配置 -->
  10. <filter>
  11. <filter-name>springSecurityFilterChain</filter-name>
  12. <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
  13. </filter>
  14. <filter-mapping>
  15. <filter-name>springSecurityFilterChain</filter-name>
  16. <url-pattern>/*</url-pattern>
  17. </filter-mapping>

applicationContext-security.xml命名空间配置,官方提供了两种配置方案

第一种、命名空间用beans开头,但是在配置中一直需要用<security:*>来配置。

  1. <beans xmlns="http://www.springframework.org/schema/beans"
  2. xmlns:security="http://www.springframework.org/schema/security"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://www.springframework.org/schema/beans
  5. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  6. http://www.springframework.org/schema/security
  7. http://www.springframework.org/schema/security/spring-security.xsd">
  8. ...
  9. </beans>

第二种、命名空间用security开头,在配置中不需要security前缀,但是bean的配置需要用<beans:bean>配置。

  1. <beans:beans xmlns="http://www.springframework.org/schema/security"
  2. xmlns:beans="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://www.springframework.org/schema/beans
  5. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  6. http://www.springframework.org/schema/security
  7. http://www.springframework.org/schema/security/spring-security.xsd">
  8. ...
  9. </beans:beans>

到此为止SpringSecurity的环境配置已基本完成

命名空间的配置可在spring的官方文档,第4章 Security Namespace Configuration 中找到,一下附上链接地址

http://docs.spring.io/spring-security/site/docs/3.2.0.RELEASE/reference/htmlsingle/#ns-config

Spring Security教程的更多相关文章

  1. Spring Security教程(五):自定义过滤器从数据库从获取资源信息

    在之前的几篇security教程中,资源和所对应的权限都是在xml中进行配置的,也就在http标签中配置intercept-url,试想要是配置的对象不多,那还好,但是平常实际开发中都往往是非常多的资 ...

  2. Spring Security教程(八):用户认证流程源码详解

    本篇文章主要围绕下面几个问题来深入源码: 用户认证流程 认证结果如何在多个请求之间共享 获取认证用户信息 一.用户认证流程 上节中提到Spring Security核心就是一系列的过滤器链,当一个请求 ...

  3. Spring Security教程(三):自定义表结构

    在上一篇博客中讲解了用Spring Security自带的默认数据库存储用户和权限的数据,但是Spring Security默认提供的表结构太过简单了,其实就算默认提供的表结构很复杂,也不一定能满足项 ...

  4. Spring Security教程(二):通过数据库获得用户权限信息

    上一篇博客中,Spring Security教程(一):初识Spring Security,我把用户信息和权限信息放到了xml文件中,这是为了演示如何使用最小的配置就可以使用Spring Securi ...

  5. 临远的spring security教程

    为啥选择Spring Security 欢迎阅读咱们写的Spring Security教程,咱们既不想写一个简单的入门教程,也不想翻译已有的国外教程.咱们这个教程就是建立在咱们自己做的OA的基础上,一 ...

  6. Spring Security 教程 大牛的教程

    https://www.iteye.com/blog/elim-2247073 Spring Security 教程 Spring Security(20)——整合Cas Spring Securit ...

  7. Spring Security教程(三)

    在上一篇博客中讲解了用Spring Security自带的默认数据库存储用户和权限的数据,但是Spring Security默认提供的表结构太过简单了,其实就算默认提供的表结构很复杂,也不一定能满足项 ...

  8. Spring Security教程(二)

    上一篇博客中,Spring Security教程(一),我把用户信息和权限信息放到了xml文件中,这是为了演示如何使用最小的配置就可以使用Spring Security,而实际开发中,用户信息和权限信 ...

  9. Spring Security教程(二):自定义数据库查询

    Spring Security教程(二):自定义数据库查询   Spring Security自带的默认数据库存储用户和权限的数据,但是Spring Security默认提供的表结构太过简单了,其实就 ...

  10. Spring Security教程系列(一)基础篇-1

    第 1 章 一个简单的HelloWorld 第 1 章 一个简单的HelloWorld Spring Security中可以使用Acegi-1.x时代的普通配置方式,也可以使用从2.0时代才出现的命名 ...

随机推荐

  1. Python简记

    1.字符换行: print('ab \ncd \nef')

  2. android设置组件透明度

    textremind.setBackgroundColor(Color.argb(178, 0, 0, 0));  //背景透明度 textremind.setTextColor(Color.argb ...

  3. Java 泛型 泛型代码和虚拟机

    Java 泛型 泛型代码和虚拟机 @author ixenos 类型擦除.原始类型.给JVM的指令.桥方法.Java泛型转换的事实 l  类型擦除(type erasure) n  Java泛型的处理 ...

  4. 二分法经典习题——HDU1969

    #include <iostream>#include <cmath>#include <iomanip>using namespace std; double p ...

  5. Linux help websites

    FAQ

  6. 关于oracle数据库(8)查询2

    筛选数据,直接加where条件,并且and,或者or 使用rownum获取前N条数据 select * from 表名 where rownum <= 数字; 如:获取前5条数据 select ...

  7. linux下ClamAV使用

    第一步:Clamav下载http://www.clamav.net/downloads#yuminstall wget –y第二步:创建clamav用户和组groupaddclamav   (创建cl ...

  8. ClassLoader类加载解惑

    1.通过类加载器获取路径: String path = Thread.currentThread().getContextClassLoader().getResource("." ...

  9. angularJS 系列(七)---指令

    ----------------------------------------------------------------------------------- 原文:https://www.s ...

  10. bootsraps ch1

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name ...