springSecurity5 重定向登录页面后 报错:尝试清除 Cookie.net::ERR_TOO_MANY_REDIRECTS status:200
2024-09-04 00:31:56
springSecurity5 使用:
http.formLogin().loginPage("/login");
报错如下图:
springsucurity5 中 需要给 自己定义的请求加权限:
失败代码如下:
public class MySecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
//定制请求的授权规则
http.authorizeRequests().antMatchers("/").permitAll()
.antMatchers("/manage/**").hasRole("manage")
.antMatchers("/view/**").hasRole("view")
.antMatchers("/db/**").hasRole("db").anyRequest().authenticated();
http.formLogin().loginPage("/login");
修正后代码如下:
public class MySecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/").permitAll()
.antMatchers("/login").permitAll()
.antMatchers("/manage/**").hasRole("manage")
.antMatchers("/view/**").hasRole("view")
.antMatchers("/db/**").hasRole("db").anyRequest().authenticated();
//http.formLogin();
http.formLogin().loginPage("/login");
最新文章
- Openjudge 1.3-04 垂直直方图
- Iterator之ListIterator简介
- POJ 1060 Modular multiplication of polynomials(多项式的加减乘除,除法转化成减法来求)
- 从一点儿不会开始——Unity3D游戏开发学习(二) ——GUI控件之Button
- leetcode面试准备:Lowest Common Ancestor of a Binary Search Tree &; Binary Tree
- 【USACO 2.3.5】控制公司
- Linux系统下目录的权限意义
- Oracle11g手动创建数据库方法
- BZOJ.4072.[SDOI2016]征途(DP 斜率优化)
- Code Chef JUMP(递推+树状数组+李超线段树)
- vue微信分享链接添加动态参数
- 有关集合的foreach循环里的add/remove
- php-excel 与 laravel-excel
- jquery添加html代码的几种方法
- 任务05—学习 MARKDOWN 语言
- Python3.7安装pyspider
- 解决调用Office组件的问题
- python实现剑指offer删除链表中重复的节点
- iPad开发简单介绍
- js-判断移动端用户是横屏放的还是竖屏放的