我正在尝试将我的资源的子文件夹映射到服务器 index.html 和关联的图像。
我的资源位于文件夹资源/a/b/c 中。(即资源/a/b/c/index.html)
我希望可以从我的根路径 ( http://localhost:8080/index.html ) 访问这个 html 页面。
我正在扩展 WebMvcConfigurerAdapter 来配置映射。我尝试了几条路径,但到目前为止没有任何效果。
@SpringBootApplication
public class Application extends WebMvcConfigurerAdapter
{
public static void main(String[] args)
{
SpringApplication.run(Application.class, args);
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
registry.addResourceHandler("/**").addResourceLocations(
"classpath:/resources/a/b/c",
"classpath:/a/b/c",
"/resources/a/b/c",
"/a/b/c",
"classpath:resources/a/b/c",
"classpath:a/b/c",
"resources/a/b/c",
"a/b/c");
}
}
有人可以给我一些指导吗?
谢谢