Spring Security 3.1.3最小入门配置及实例下载
2013-12-11 18:00
656 查看
因为公司项目要用spring security管理权限,但是作为一个极其标准的菜鸟,只最略微接触了一些spring的东西,基本不算入门,研究了一整天才做出了最简单的demo,有基础了想提高的大牛们就不用往下看了,这个是最最基本的入门配置,附有实例下载,算是给那些也从来没有接触过的和我一样的菜鸟们吧。
这个例子全部都是配置出来的,没有用到任何JAVA代码,我想既然是学,对于新手来说把最简单的东西弄懂了后面一是比较有信心,二是循序渐进。网上的教程很多,但是我感觉很少有那种非常简单的(最后发现了个简单的教程,我放在附件里你们可以下载,挺有帮助),而且直接可以运行的实例基本上需要更改的太多,所以才把这个上传,希望别笑我,拜托啦。
整个项目的目录是这样的
废话不多说,直接贴代码:
1.web.xml
2.application-security.xml
3.jsp什么的随便写点就好。
实例和教程的下载地址在下面了,话说,怎么才能添加附件?
Spring Security 3.1.3配置实例
SpringSecurity_3.0_教程
这个例子全部都是配置出来的,没有用到任何JAVA代码,我想既然是学,对于新手来说把最简单的东西弄懂了后面一是比较有信心,二是循序渐进。网上的教程很多,但是我感觉很少有那种非常简单的(最后发现了个简单的教程,我放在附件里你们可以下载,挺有帮助),而且直接可以运行的实例基本上需要更改的太多,所以才把这个上传,希望别笑我,拜托啦。
整个项目的目录是这样的
废话不多说,直接贴代码:
1.web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:application-security.xml </param-value> </context-param> <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> <!-- 监听spring配置文件 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 监听Session --> <listener> <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class> </listener> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
2.application-security.xml
<?xml version="1.0" encoding="UTF-8"?> <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.2.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> <http pattern="/no.jsp" security="none"/> <http auto-config="true" access-denied-page="/no.jsp"> <!-- <intercept-url pattern="/**" access="ROLE_USER" /> --> <intercept-url pattern="/index1.jsp" access="ROLE_USER" /> <intercept-url pattern="/index2.jsp" access="ROLE_DAZA" /> <intercept-url pattern="/index3.jsp" access="ROLE_MANAGER" /> <!-- <form-login login-page="/login.jsp" login-processing-url="/gologin" authentication-failure-url="/no.jsp" default-target-url="/index.jsp"/> --> <logout invalidate-session="true" logout-url="/logout.jsp"/> </http> <authentication-manager alias="appAuthenticationManager"> <authentication-provider> <user-service> <user name="user1" password="111111" authorities="ROLE_USER" /> <user name="user2" password="222222" authorities="ROLE_DAZA" /> <user name="user3" password="333333" authorities="ROLE_MANAGER,ROLE_DAZA,ROLE_USER" /> </user-service> </authentication-provider> </authentication-manager> </beans:beans>
3.jsp什么的随便写点就好。
实例和教程的下载地址在下面了,话说,怎么才能添加附件?
Spring Security 3.1.3配置实例
SpringSecurity_3.0_教程
相关文章推荐
- Spring Security 3.x完整入门配置教程及其代码下载
- mybatis入门配置详解及实例下载
- Spring Security 3.x完整入门配置教程及其代码下载
- Spring MVC用户注册配置入门教程及其代码实例demo下载
- Spring MVC基于注解配置入门教程及其代码实例
- VxWorks BSP主要配置文件 config.h , Makefile 注解和 BSP生成下载实例
- Spring Security3.1 最新配置实例
- quartz spring配置实例代码demo下载
- springmvc注解配置例子的实例代码下载
- salesforce 零基础开发入门学习(一)Salesforce功能介绍,IDE配置以及资源下载
- MyEclipse2014快速配置SpringMVC入门实例
- Struts2+Spring+Ibatis用户注册、登录、管理入门学习实例源码下载
- Spring Security3.1 最新配置实例
- SpringMVC入门教程及其原理讲解和实例代码下载
- Photoshop入门:网上下载的滤镜应用实例
- (转载)directshow的下载、VC2008中的配置、入门教程以及如何在opencv中使用
- Zend Framework入门之环境配置及第一个Hello World示例(附demo源码下载)
- Spring 入门配置实例
- Opencv4android的Android Studio环境配置及项目实例下载
- Spring Security3.1 最新配置实例