SpringWebSecurity如何使用2登录表单
我在SpringWebSecurity中创建了两个登录表单。(用户,管理员)但是,如果在用户登录页面上登录失败,它将返回到用户登录页面,但是如果在管理员登录页面上登录失败,它将返回到用户登录页面,而不是管理员登录页面。我做错什么了吗SpringWebSecurity如何使用2登录表单,spring,spring-boot,websecurity,Spring,Spring Boot,Websecurity,我在SpringWebSecurity中创建了两个登录表单。(用户,管理员)但是,如果在用户登录页面上登录失败,它将返回到用户登录页面,但是如果在管理员登录页面上登录失败,它将返回到用户登录页面,而不是管理员登录页面。我做错什么了吗 httpSecurity .csrf() .disable() .authorizeRequests() .requestMatchers(PathRequest.toS
httpSecurity
.csrf()
.disable()
.authorizeRequests()
.requestMatchers(PathRequest.toStaticResources().atCommonLocations())
.permitAll()
.antMatchers("/registerUser", "/saveUser", "/admin")
.permitAll()
.anyRequest()
.authenticated()
.and()
.formLogin()
.loginPage("/admin")
.loginProcessingUrl("/login-process")
.defaultSuccessUrl("/center", true)
.failureUrl("/Admin/admin?error=ture")
.failureHandler(failureHandler())
.permitAll();
httpSecurity.formLogin()
.loginPage("/login")
.loginProcessingUrl("/login-process")
.defaultSuccessUrl("/center", true)
//.failureUrl("/login")
.failureUrl("/login.html?error=true")
.permitAll()
.and()
.rememberMe()
.rememberMeParameter("remember-me")
.key(REMEMBER_ME_TOKEN)
.tokenValiditySeconds(Math.toIntExact(Duration.ofDays(30).getSeconds()))
.userDetailsService(userService);
我认为问题可能出现在这里-
.failureUrl(“/Admin/Admin?error=true”)
true
-nottrue
那么我可以将true更改为not true吗?我会试试的。不工作不是真的你有一个输入错误:nottrue
,改为true
I fixed true。。但现在确实在工作