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");

最新文章

  1. Openjudge 1.3-04 垂直直方图
  2. Iterator之ListIterator简介
  3. POJ 1060 Modular multiplication of polynomials(多项式的加减乘除,除法转化成减法来求)
  4. 从一点儿不会开始——Unity3D游戏开发学习(二) ——GUI控件之Button
  5. leetcode面试准备:Lowest Common Ancestor of a Binary Search Tree & Binary Tree
  6. 【USACO 2.3.5】控制公司
  7. Linux系统下目录的权限意义
  8. Oracle11g手动创建数据库方法
  9. BZOJ.4072.[SDOI2016]征途(DP 斜率优化)
  10. Code Chef JUMP(递推+树状数组+李超线段树)
  11. vue微信分享链接添加动态参数
  12. 有关集合的foreach循环里的add/remove
  13. php-excel 与 laravel-excel
  14. jquery添加html代码的几种方法
  15. 任务05—学习 MARKDOWN 语言
  16. Python3.7安装pyspider
  17. 解决调用Office组件的问题
  18. python实现剑指offer删除链表中重复的节点
  19. iPad开发简单介绍
  20. js-判断移动端用户是横屏放的还是竖屏放的

热门文章

  1. 使nginx归于systemd管理
  2. STM32 常用词汇释义
  3. python 删除/app/*/logs/*/*.logs指定多少天的文件
  4. Arduino-数学函数
  5. win10如何设置软件开机启动
  6. 使用Docker安装PaddlePaddle安装过程中出现的几个问题
  7. SQL GROUP BY两个列
  8. IDEA设置Ctrl+滚轮调整字体大小
  9. 转: Github上关于iOS的各种开源项目集合
  10. Xcode工程文件pbxproj