原文地址: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. pdf 电子书分享

    http://yunpan.cn/cLgXntGmIas7A 访问密码 7d04 来自为知笔记(Wiz)

  2. Google Dremel 原理 - 如何能3秒分析1PB

    简介 Dremel 是Google 的“交互式”数据分析系统.可以组建成规模上千的集群,处理PB级别的数据.MapReduce处理一个数据,需要分钟级的时间.作为MapReduce的发起人,Googl ...

  3. 谷歌Dremel即时数据分析解决方案

    Hadoop技术已经无处不在.不管是好是坏,Hadoop已经成为大数据的代名词.短短几年间,Hadoop从一种边缘技术成为事实上的标准.看来,不仅现在Hadoop是企业大数据的标准,而且在未来,它的地 ...

  4. 大数据时代之hadoop(一):hadoop安装

    1.hadoop版本介绍 0.20.2版本以前(不含该版本)的配置文件都在default.xml中. 0.20.x以后的版本不含有eclipse插件的jar包,由于eclipse的版本不一,所以就需要 ...

  5. 印象烟大PPT大赛

    下面为获奖人员 王志恒一等奖 姜云飞.任子仪二等奖 田正相,庄棫麟,陈德昊三等奖.

  6. GitHub版本控制工具入门(一)

    你还在使用 SVN 吗? 那就太 low 了... 概述 要了解 github 要从另外一个软件开始,那就是 git ,他的中文意思是 傻子 ,这款软件为什么要起一个这么傻的名字呢? 那你就需要了解一 ...

  7. apache动态添加模块

    Apache已经安装完毕并投入运行,但是后来却发现部分模块没有加载,当然有两个方法: 1. 一是完全重新编译Apache, 再安装 2. 编译模块为SO文件,使用LoadModule指令加载扩展模块. ...

  8. CMake VS工程总结

    1.设置输出后缀 set(CMAKE_DEBUG_POSTFIX "d") 2.设置输出目录 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_ ...

  9. jq的siblings对a标签不起效

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  10. UIScrollView 加载多个view view还可以交换顺序(2)

    在上的代码中 UIview都在一个页面 要是每一个view对应一个页面 操作每一个view代码都在viewcontroller里面就会很乱,那么我们就将view重新做一下 创建想要的页面继承与view ...