Spring
Boot的WebMvcAutoConfigurationAdapter默认情况下(在addStaticIndexHtmlViewControllers方法中)注册从“
/”到“ /index.html”的转发。因此,您必须在路径“ /index.html”下注册视图。
可以
@RequestMapping("/index.html")在控制器上执行以下操作:@Configurationpublic class WebConfig extends WebMvcConfigurerAdapter{ @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/index.html").setViewName("index"); }}另一种选择是覆盖
WebMvcAutoConfigurationAdapter和禁用
WebMvcAutoConfiguration。



