从spring迁移到spring引导(spring安全验证不工作)

snvhrwxg  于 2021-09-29  发布在  Java
关注(0)|答案(1)|浏览(441)
  1. @Override
  2. protected void configure(HttpSecurity http) throws Exception {
  3. http.csrf().and().headers().and().anonymous().disable()
  4. .formLogin().loginPage("/login.html").failureHandler(this.authenticationFailureHandler)
  5. .defaultSuccessUrl("/main").loginProcessingUrl("/j_spring_security_check")
  6. .usernameParameter("j_username").passwordParameter("j_password")
  7. .and()
  8. .logout().logoutUrl("/j_spring_security_logout").logoutSuccessUrl("/login.html");
  9. }

当我点击登录按钮时,它会将我重定向到

7bsow1i6

7bsow1i61#

将其添加到安全配置类中。authorizerequests().antmatchers(“/login*”).permitall()
删除以下和().headers()和().anonymous()

  1. @Override
  2. protected void configure(HttpSecurity http) throws Exception {
  3. http.csrf().disable()
  4. .formLogin().loginPage("/login.html").failureHandler(this.authenticationFailureHandler)
  5. .defaultSuccessUrl("/main").loginProcessingUrl("/j_spring_security_check")
  6. .usernameParameter("j_username").passwordParameter("j_password")
  7. .and()
  8. .logout().logoutUrl("/j_spring_security_logout").logoutSuccessUrl("/login.html");
  9. }

相关问题