最佳答案
我对 Java 和 Spring 都是新手。
如何将我的应用程序根 http://localhost:8080/
映射到静态 index.html
?
如果我导航到 http://localhost:8080/index.html
它的工作正常。
我的应用程序结构是:
我的 config\WebConfig.java
是这样的:
@Configuration
@EnableWebMvc
@ComponentScan
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**").addResourceLocations("/");
}
}
我试图添加 registry.addResourceHandler("/").addResourceLocations("/index.html");
,但它失败了。