标签:iis efault smi stat soa d3d source uft cm5
{
"name": "spring.resources.static-locations",
"type": "java.lang.String[]",
"description": "Locations of static resources. Defaults to classpath:[\/META-INF\/resources\/, \/resources\/, \/static\/, \/public\/].",
"sourceType": "org.springframework.boot.autoconfigure.web.ResourceProperties",
"defaultValue": [
"classpath:\/META-INF\/resources\/",
"classpath:\/resources\/",
"classpath:\/static\/",
"classpath:\/public\/"
]
}
请求路径:/image/**
请求文件:classpath:/images/
@Configurationpublic class ImageMvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/image/**")
.addResourceLocations("classpath:/images/");
}
}
请求路径:/resources/**
请求文件:/public, classpath:/static/
@Configuration@EnableWebMvcpublic class WebConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**")
.addResourceLocations("/public", "classpath:/static/")
.setCachePeriod(31556926);
}
}
spring:
mvc:
static-path-pattern: /image/**
resources:
static-locations: classpath:/images/
标签:iis efault smi stat soa d3d source uft cm5
原文地址:https://www.cnblogs.com/yang21/p/11918097.html