SpringSecurity实现后台管理员登录(二)
SpringSecurity后台 实现 登录 管理员
2023-09-11 14:21:55 时间
需求:login.ftl页面中登录成功后进入index.ftl页面中
一、pom.xml中添加json转换相关的包
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- <version>2.4.4</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>2.4.4</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- <version>2.4.4</version>
- </dependency>
二、applicationContext-mvc.xml中添加json转换相关的配置
- <!--token 拦截校验 -->
- <mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" />
- <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
- <property name="favorPathExtension" value="false" />
- <property name="favorParameter" value="true" />
- <property name="ignoreAcceptHeader" value="false" />
- <property name="mediaTypes">
- <value>
- atom=application/atom+xml
- html=text/html
- json=application/json
- *=*/*
- </value>
- </property>
- </bean>
三、applicationContext-security.xml中
将<intercept-url pattern="/service/index/index"access="ROLE_AUTHORITY"/>
改为<intercept-url pattern="/service/index/index" />
这里只是要实现简单的登录功能,所以没有设计权限。加了access=” "ROLE_AUTHORITY”会导致无法登录。
四、实现效果
相关文章
- 微服务技术系列教程(49)-SpringSecurity
- SpringSecurity自定义响应异常信息
- SpringSecurity整合SpringBoot
- SpringSecurity认证流程
- 基于SpringSecurity和JWT的用户访问认证和授权
- SpringSecurity基于数据库RBAC数据模型控制权限
- SpringSecurity实现短信验证码登录(Token)
- SpringSecurity实现图形验证码功能
- SpringSecurity如何在代码中获取认证用户信息
- SpringSecurity使用注解实现匿名访问
- SpringBoot+Vue前后端分离,使用SpringSecurity完美处理权限问题
- SpringSecurity系列(四) Spring Security 实现权限树形菜单
- SpringBoot 实现登录验证码(附集成SpringSecurity)