可以在⾃⼰的MvcConfig下添加如下代码
privatestaticfinal String[] CLASSPATH_RESOURCE_LOCATIONS = {
“classpath:/META-INF/resources/”, “classpath:/resources/”,
“classpath:/static/”, “classpath:/public/” };
@Override
publicvoid addResourceHandlers(ResourceHandlerRegistry registry) {
if (!registry.hasMappingForPattern(“/webjars/“)) {
registry.addResourceHandler(”/webjars/”).addResourceLocations(
“classpath:/META-INF/resources/webjars/”);
}
if (!registry.hasMappingForPattern(“/“)) {
registry.addResourceHandler(”/”).addResourceLocations(
CLASSPATH_RESOURCE_LOCATIONS);
}
}
Springboot访问不了static⽂件夹的静态资源,配置拦截器出 现“Nomappin。。。
最新推荐文章于 2024-08-19 18:05:17 发布