设为首页 加入收藏

TOP

Spring Security身份认证之HelloSpringSecurity(附源码)(一)
2015-02-02 14:11:34 来源: 作者: 【 】 浏览:67
Tags:Spring Security 身份认证 HelloSpringSecurity 源码

本文源代码下载


------------------------------------------分割线------------------------------------------


具体下载目录在 /2015年资料/1月/22日/Spring Security身份认证之HelloSpringSecurity(附源码)


------------------------------------------分割线------------------------------------------


开发环境如下:


项目目录结构如下:


Spring Security身份认证之HelloSpringSecurity(附源码)


1.新建Maven Project,对Maven不熟悉的童鞋请自行充电,现在这个念头不学习Maven绝对是不行的。


Spring Security身份认证之HelloSpringSecurity(附源码)


2. 在Pom.xml添加相关jar依赖。


? xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
? 4.0.0
? com.favccxx.favsecurity?
? HelloSpringSecurity?
? war?
? 0.0.1-SNAPSHOT?
? HelloSpringSecurity Maven Webapp
? http://maven.apache.org
? ?
? ?
? ? ? ? ? 3.2.8.RELEASE
?

? ?
? ? ?
? ? ? ?
? ? ? junit?
? ? ? junit
? ? ? 3.8.1
? ? ? test
? ?
?
? ? ?
? ? ?
? ?
? ? ? ? org.springframework
? ? ? ? spring-core
? ? ? ? ${spring.version}
? ?

? ?
? ? ? ? org.springframework
? ? ? ? spring-webmvc
? ? ? ? ${spring.version}
? ?

? ?
? ? ? ? org.springframework
? ? ? ? spring-beans
? ? ? ? ${spring.version}
? ?

? ?
? ? ? ? org.springframework
? ? ? ? spring-context
? ? ? ? ${spring.version}
? ?

? ?
? ? ? ? org.springframework
? ? ? ? spring-aop
? ? ? ? ${spring.version}
? ?

? ?
? ? ? ? org.springframework
? ? ? ? spring-tx
? ? ? ? ${spring.version}
? ?






? ?
? ? ? ? org.freemarker
? ? ? ? freemarker
? ? ? ? 2.3.20
? ?

? ?
? ? ? ? org.springframework
? ? ? ? spring-orm
? ? ? ? ${spring.version}
? ?

? ? ?
? ? ?
? ? ?
? ? ? ? org.springframework.security
? ? ? ? spring-security-web
? ? ? ? 3.2.5.RELEASE?
? ? ?
?
? ? ?
? ? ? ? org.springframework.security
? ? ? ? spring-security-config
? ? ? ? 3.2.5.RELEASE
? ? ?

? ? ? ?
? ? ?
? ? ? ? ? jstl
? ? ? ? ? jstl
? ? ? ? ? 1.2
? ? ?

?

?
? ? HelloSpringSecurity
?


3. 配置web.xml,在容器启动时加载Spring MVC的配置文件与Spring Security的配置文件。



? ? xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
? ? xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
? ? Hello Spring Security
? ? ?
? ?
? ? ? ? contextConfigLocation
? ? ? ?
? ? ? ? ? ? classpath:springSecurity.xml
? ? ? ?

? ?

? ? ?
? ?
? ? ? ? org.springframework.web.context.ContextLoaderListener
? ?

? ? ?
? ?
? ? ? ? springSecurityFilterChain
? ? ? ? org.springframework.web.filter.DelegatingFilterProxy
? ?

? ?
? ? ? ? springSecurityFilterChain
? ? ? ? /*
? ?

? ? ?
? ?
? ? ? ? springMVC
? ? ? ? org.springframework.web.servlet.DispatcherServlet
? ? ? ?
? ? ? ? ? ? contextConfigLocation
? ? ? ? ? ? classpath:spring-context.xml
? ? ? ?

? ? ? ? 1
? ?

? ?
? ? ? ? springMVC
? ? ? ? /
? ?

?


4. SpringSecurity.xml配置文件如下


? ? xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
? ? xmlns:security="http://www.springframework.org/schema/security"
? ? 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.2.xsd">
?
? ?
? ? ? ?
? ? ? ?
? ?

? ? ?
? ? ?
? ?
? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ?
? ? ? ? ? ?

? ? ? ?
?
? ?

? ? ?


5.spring-context.xml配置文件如下



? ? xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
? ? xmlns:context="http://www.springframework.org/schema/context"
? ? xmlns:mvc="http://www.springframework.org/schema/mvc"
? ? xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
? ? ? ? http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
? ? ? ? http://w

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C++2015前瞻 下一篇Android JSON解析数据

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: