在安全性的角度上浏览器不允许直接访问本地磁盘的资源

 <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);
    }
}

猜你喜欢

转载自blog.csdn.net/qq_41410615/article/details/107294871