spring boot front page not found js, css files

Page can not be found when accessing the resource files, the path is correct, but is not accessible.

Finally the Internet to find some way to try it, add the following paragraph problem is solved.

 1 @SpringBootApplication
 2 public class HouseWebApplication extends WebMvcConfigurationSupport {
 3 
 4     public static void main(String[] args) {
 5         SpringApplication.run(HouseWebApplication.class, args);
 6     }
 7 
 8     // 配置静态资源文件路径
 9     @Override
10     protected void addResourceHandlers(ResourceHandlerRegistry registry) {
11         registry.addResourceHandler("/static/**")
12                 .addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX + "/static/");
13         super.addResourceHandlers(registry);
14     }
15 }

 

Guess you like

Origin www.cnblogs.com/rabbitli/p/11262651.html