我有我的WebSecurityConfigurerAdapter configure()方法
http.authorizeRequests().antMatchers("/static/**").permitAll().anyRequest().authenticated().and()
.formLogin().loginPage("/login")
// Redirection after login
.defaultSuccessUrl("/home", true).permitAll().and().logout()
// logout link. Check if there is no conflict with SAML
.logoutRequestMatcher(new AntPathRequestMatcher("/saml/logout")).deleteCookies("JSESSIONID")
.invalidateHttpSession(true).logoutSuccessUrl("/").permitAll();
如果用户尝试访问/home
,如何将登录用户重定向到/login
?
PS - 我的控制器代码
@RequestMapping(method = RequestMethod.GET, value = {"/login"})
public String getIndexPage() {
return LOGIN_PAGE;
}
@RequestMapping(method = RequestMethod.GET, value = {"/"})
public String getHomePage() {
return "redirect:/home";
}