내 리소스의 하위 폴더를 서버 index.html 및 이미지와 연결하려고합니다.하위 폴더의 Spring 부트 매핑 리소스
내 리소스는 폴더 리소스/a/b/c 내에 있습니다. (예 : resources/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",
"https://stackoverflow.com/a/b/c",
"classpath:resources/a/b/c",
"classpath:a/b/c",
"resources/a/b/c",
"a/b/c");
}
}
누군가 내게 이에 대한 지침을 줄 수 있습니까?
덕분에 documentation에서
리디렉션 '@Override를 추가하십시오. public void addViewControllers (ViewControllerRegistry registry) { registry.addRedirectViewController ("index.html", "/a/b/c/index.html"); super.addViewController (레지스트리); }' – azl