在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/Java/ 為什么我使用springMVC無(wú)法攔截根目錄請(qǐng)求?總是使用默認(rèn)的index.ht

為什么我使用springMVC無(wú)法攔截根目錄請(qǐng)求?總是使用默認(rèn)的index.html

spring攔截 localhost:8080/1可以攔截到我的chat頁(yè)面,而攔截根目錄就攔截不到,回去訪問(wèn)默認(rèn)的index頁(yè)面;

控制臺(tái)日志中有這么幾行日志輸出

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

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

spring security的配置

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

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

        http.authorizeRequests()
                .anyRequest()
                .authenticated()
                .and()
                //開(kāi)啟默認(rèn)登錄頁(yè)面
                .formLogin()
                //默認(rèn)登錄頁(yè)面
                .loginPage("/login")
                //默認(rèn)登錄成功跳轉(zhuǎn)頁(yè)面
                .defaultSuccessUrl("/")
                .permitAll()
                .and()
                //設(shè)置注銷
                .logout()
                .permitAll();
    }
   }
回答
編輯回答
離觴

index.html是springboot使用thymeleaf后的默認(rèn)配置

2017年1月23日 02:42