Why can't I intercept root requests using springMVC? Always use the default index.html

spring intercepts localhost:8080/1 to intercept my chat page, but not to the root directory. Go back to the default index page;

there are several lines of log output in the console log

2018-06-04 15:46:03.601  INFO 15836 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/login] onto handler of type [class org.springframework.web.servlet.mvc.ParameterizableViewController]
2018-06-04 15:46:03.601  INFO 15836 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Root mapping to handler of type [class org.springframework.web.servlet.mvc.ParameterizableViewController]
2018-06-04 15:46:03.601  INFO 15836 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/1] onto handler of type [class org.springframework.web.servlet.mvc.ParameterizableViewController]
2018-06-04 15:46:03.663  INFO 15836 --- [  restartedMain] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page template: index

configuration of springMVC

@Configuration
public class WebMvcConfg implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/login").setViewName("/login");
        registry.addViewController("/").setViewName("/chat");
        registry.addViewController("/1").setViewName("/chat");
    }
}

configuration of spring security

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http.authorizeRequests()
                .anyRequest()
                .authenticated()
                .and()
                //
                .formLogin()
                //
                .loginPage("/login")
                //
                .defaultSuccessUrl("/")
                .permitAll()
                .and()
                //
                .logout()
                .permitAll();
    }
   }

index.html is the default configuration of springboot after using thymeleaf


because the thymeleaf is configured to visit the index.html page under the static folder by default,
therefore, when intercepting, you need to configure to intercept index.html
registry.addViewController ("/ index.html"). SetViewName ("login");
in this way, index.html, will be blocked to enter the login.html page when accessing the root directory

.
Menu