如果用户已经登录到主页spring boot security,则重定向用户
我有一个SpringBoot应用程序,用户可以登录并访问登录。登录后,用户仍然可以访问登录页面。我希望登录的用户没有访问登录页面的权限,而是将他们重定向到主页。我该怎么做??我正在使用SpringSecurity对用户进行身份验证 这是我当前的配置:如果用户已经登录到主页spring boot security,则重定向用户,spring,spring-boot,spring-security,Spring,Spring Boot,Spring Security,我有一个SpringBoot应用程序,用户可以登录并访问登录。登录后,用户仍然可以访问登录页面。我希望登录的用户没有访问登录页面的权限,而是将他们重定向到主页。我该怎么做??我正在使用SpringSecurity对用户进行身份验证 这是我当前的配置: http .authorizeRequests() .antMatchers("/css/**","/js/**","/register/**").permitAl
http
.authorizeRequests()
.antMatchers("/css/**","/js/**","/register/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/home")
.permitAll()
.and()
.logout()
.logoutUrl("/logout")
.logoutSuccessUrl("/login")
.invalidateHttpSession(true)
.deleteCookies("JSESSIONID")
.permitAll()
如果您不想使用筛选器,请在登录控制器@GetRequest(“/login”)中按principal.getName()检查用户详细信息,如果不为空,请返回主视图。如果对您有效,请将其标记为正确答案,谢谢:)我没有问这个问题。:)哦,对不起,我刚刚注意到了同一个姓:)我没有使用任何控制器登录,spring security正在处理登录部分@k-wasilewskiOk,所以我的建议是:只需创建一个,这很简单