springboot项目静态资源导入失败

解决静态资源导入失败问题

在使用thymeleaf引擎时静态资源无法导入,出现 No mapping for GET /css/bootstrap.min.css

添加MVC配置类

@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private  UserArgumentResolver userArgumentResolver;

    private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
            "classpath:/META-INF/resources/", "classpath:/resources/",
            "classpath:/static/", "classpath:/public/" };

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**")
                .addResourceLocations(CLASSPATH_RESOURCE_LOCATIONS);

    }

  
}
上一篇:双亲委派考点


下一篇:原型设计工具——axure认识与使用