关于后端存储文件后访问出现Not allowed to load local resource

lankeren

添加配置类,创建虚拟路径 映射到 文件的路径

/**
 * @author lankeren
 * @ClassName MyWebConfig
 * @Deacription:
 * @create: 2020-06-22 11:04
 */
@Configuration
public class MyWebConfig implements WebMvcConfigurer {

    /**
     * Add handlers to serve static resources such as images, js, and, css
     * files from specific locations under web application root, the classpath,
     * and others.
     *
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/picFiles/**").addResourceLocations("file:E:/JavaWorkPlace/School/auctiononlinesys/src/main/resources/static/imgs/goods/");
    }
}
阅读 1.4k

有效果,达到目标的努力是真努力,其余不能称之为努力。

44 声望
5 粉丝
0 条评论
你知道吗?

有效果,达到目标的努力是真努力,其余不能称之为努力。

44 声望
5 粉丝
宣传栏