详解Spring Security 简单配置

网友投稿 264 2023-05-12


详解Spring Security 简单配置

开发环境

maven

idea

jdk 1.8

tomcat 8

配置spring mvc + spring security

pom.xml

4.3.8.RELEASE

4.2.2.RELEASE

org.springframework

spring-context

${spring.version}

org.springframework

spring-webmvc

${spring.version}

org.springframework.security

spring-security-core

${spring-sercurity.version}

org.springframework.security

spring-security-web

${spring-sercurity.version}

org.springframework.security

spring-security-config

${spring-sercurity.version}

spring mvc 使用的是4.3.8版本,spring security 使用的是4.2.2版本。

spring-mvc-servlet.xml

xmlns:context="http://springframework.org/schema/context"

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xsi:schemahttp://Location="

http://springframework.org/schema/beans

http://springframework.org/schema/beans/spring-beans-4.0.xsd

http://springframework.org/schema/context

http://springframework.org/schema/context/spring-context-4.0.xsd">

/WEB-INF/pages/

.jsp

xmlns:context="http://springframework.org/schema/context"

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xsi:schemahttp://Location="

http://springframework.org/schema/beans

http://springframework.org/schema/beans/spring-beans-4.0.xsd

http://springframework.org/schema/context

http://springframework.org/schema/context/spring-context-4.0.xsd">

/WEB-INF/pages/

.jsp

spring-security.xml

xmlns="http://springframework.org/schema/security"

xmlns:beans="http://springframework.org/schema/beans"

xmlns:p="http://www.springframework.org/schema/p"

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xmlns:context="http://springframework.org/schema/context"

xsi:schemaLocation="http://springframework.org/schema/beans

http://springframework.org/schema/beans/spring-beans.xsd

http://springframework.org/schema/context

http://springframework.org/schema/context/spring-context.xsd

http://springframework.org/schema/security

http://springframework.org/schema/security/spring-security.xsd">

xmlns="http://springframework.org/schema/security"

xmlns:beans="http://springframework.org/schema/beans"

xmlns:p="http://www.springframework.org/schema/p"

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xmlns:context="http://springframework.org/schema/context"

xsi:schemaLocation="http://springframework.org/schema/beans

http://springframework.org/schema/beans/spring-beans.xsd

http://springframework.org/schema/context

http://springframework.org/schema/context/spring-context.xsd

http://springframework.org/schema/security

http://springframework.org/schema/security/spring-security.xsd">

web.xml

xmlns="http://java.sun.com/xml/ns/javaee"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"

id="WebApp_ID" version="3.0">

Archetype Created Web Application

org.springframework.web.context.ContextLoaderListener

contextConfigLocation

classpath:spring-mvc-servlet.xml,

classpath:spring-security.xml

spring-mvc

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

classpath*:spring-mvc-servlet.xml

1

spring-mvc

/

springSecurityFilterChain

org.springframework.web.filter.DelegatingFilterProxy

springSecurityFilterChain

/*

index.jsp

xmlns="http://java.sun.com/xml/ns/javaee"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"

id="WebApp_ID" version="3.0">

Archetype Created Web Application

org.springframework.web.context.ContextLoaderListener

contextConfigLocation

classpath:spring-mvc-servlet.xml,

classpath:spring-security.xml

spring-mvc

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

classpath*:spring-mvc-servlet.xml

1

spring-mvc

/

springSecurityFilterChain

org.springframework.web.filter.DelegatingFilterProxy

springSecurityFilterChain

/*

index.jsp

测试

spring会拦截所有请求,如果没有登录,则系统会跳转到spring security默认的登录页面。


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:浅谈Maven的安装及修改为阿里云下载依赖
下一篇:java中处理socket通信过程中粘包的情况
相关文章

 发表评论

暂时没有评论,来抢沙发吧~