springSecurity5 redirect login page error: attempt to clear Cookie.net::ERR_TOO_MANY_REDIRECTS status: 200

springSecurity5 use:

. http.formLogin () loginPage ( "/ login"); 
given below:

 

Request permission to add springsucurity5 need to define yourself:

Failure code as follows:

public class MySecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected  void the configure (HttpSecurity HTTP) throws Exception {
 // authorization rule customization request 
        http.authorizeRequests (). antMatchers ( "/" ) .permitAll ()
                 .antMatchers ( "/ the Manage / **"). hasRole ( "the Manage" )
                .antMatchers("/view/**").hasRole("view")
                .antMatchers("/db/**").hasRole("db").anyRequest().authenticated();
        http.formLogin().loginPage("/login");

After correcting code is as follows:

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

 

 

 

Guess you like

Origin www.cnblogs.com/belen87/p/12004004.html