1、在不配置任何路径情况下,
如果静态文件放在/resources/static/下面时,访问路径是:http://localhost:8080/index.html
2、如果按照下面代码配置则需要添加static,访问路径即为:http://localhost:8080/static/index1.html
代码块:
@Component public class WebMvcConfig implements WebMvcConfigurer { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); } }
截图: