spring security 4.2.2 入门

1、创建maven工程

新建 maven 项目,创建 spring security 配置文件 security.xml

spring security 4.2.2 入门_第1张图片

2、在pom.xml文件中增加依赖


    
        
        org.springframework.security
            spring-security-web
            4.2.2.RELEASE
        
        
            org.springframework.security
            spring-security-config
            4.2.2.RELEASE
        
        
            commons-logging
            commons-logging
            1.2
        
    


3、配置 spring.xml 文件

将下列内容复制到security.xml文件中去



    
    
        
    


4、更改web.xml文件,增加以下内容


    
        contextConfigLocation
        
            /WEB-INF/spring/security.xml
        
    
    
        springSecurityFilterChain
        org.springframework.web.filter.DelegatingFilterProxy
    
    
        springSecurityFilterChain
        /*
    
    
        org.springframework.web.context.ContextLoaderListener
    

5、发布项目,效果图如下

spring security 4.2.2 入门_第2张图片

6、项目源码

点击查看源码

7、参考

spring-security官方网站

你可能感兴趣的:(spring security 4.2.2 入门)