この構成は、springbootインターセプト静的ファイルを処理しています
コード:
インポートorg.springframework.context.annotation.Configuration; インポートorg.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; インポートorg.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration パブリック クラスのWebConfig 実装WebMvcConfigurer { / ** *静的リソースファイルを追加し、あなたが直接外部アドレスにアクセスすることができます *の@paramのレジストリを * / @Override 公共 のボイドaddResourceHandlers(ResourceHandlerRegistryレジストリ){ // 次の設定は、以下のsrc /メイン/リソース/静的ファイルへのアクセス権を持ってすることができます 。registry.addResourceHandler( "/静的/ **")addResourceLocations( "クラスパス:/静的/" ); } }