<mvc:annotation-driven/>
<mvc:resources location="/images/" mapping="/images/**"></mvc:resources>
/**
* 在安全性的角度上浏览器不允许直接访问本地磁盘的资源
* */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
@Value("${file.path.absolute}")
private String absolutePath;
@Value("${file.path.relative}")
private String relativePath;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler(relativePath+"**").addResourceLocations("file:"+absolutePath);
}
}