浏览器读取本地图片时出现Not allowed to load local resource或者404

问题遇到的现象和发生背景

出现Not allowed to load local resource,已经配置了虚拟路径也不管用,而且发生的现象就好像是根本没配置虚拟路径一样?

问题相关代码,请勿粘贴截图 .

虚拟路径是这样配的

package com.test.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class PicConfigration implements WebMvcConfigurer {
        @Override
        public void addResourceHandlers(ResourceHandlerRegistry registry) {
            registry.addResourceHandler("/file/**").addResourceLocations("file:E:/3-2109/SpringBoot1/src/main/resources/file/");
        }
    }

这是前端的界面,只粘贴相关的那部分代码了

              <td><p>
                     <a href="/file/${user.file_name!""}" target="_blank">查看附件</a>
             </p></td>


运行结果及报错内容

img

我的解答思路和尝试过的方法

看起来很明显就是虚拟路径没生效,我在前端界面把虚拟路径换成实际路径,提示的是Not allowed to load local resource,像这样虚拟路径就是404

我想要达到的结果

有人知道我这个虚拟路径有哪里弄得不对吗?还是我少了什么东西没配置?感谢!

虚拟路径 怎么配置的?