私のリソースのサブフォルダをサーバのindex.htmlに関連付けようとしています。サブフォルダのスプリングブートマッピングリソース
マイ・リソースは、フォルダ・リソース/ a/b/c内にあります。
私のルートパス(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.addRedirectViewController( "index.htmlを"、 "/a/b/c/index.html")をリダイレクト追加してみてください。 super.addViewController(レジストリ); } ' – azl