添加一个配置类WebConfigue,继承WebMvcConfigurerAdapter,放在任意包下都行
@Configuration
public class WebConfigue extends WebMvcConfigurerAdapter {
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("login.html");
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
super.addViewControllers(registry);
}
}
然后就好了