Angularjs 不允许加载本地资源:angular js spring

Angularjs 不允许加载本地资源:angular js spring,angularjs,spring,Angularjs,Spring,我在前端使用angular js,在后端使用spring boot。我成功地将图像上传到我的数据库,并将其放入本地文件夹。我的问题当我想使用ng src angular js显示此图像时,我遇到以下错误: Not allowed to load local resource: C:/Users/Public/Pictures/5ecece06-5306-4743-a003-1590e202a000-original.jpeg 我把这些图片放进了公共文件夹,和我遇到的错误是一样的。 这是我的We

我在前端使用angular js,在后端使用spring boot。我成功地将图像上传到我的数据库,并将其放入本地文件夹。我的问题当我想使用ng src angular js显示此图像时,我遇到以下错误:

Not allowed to load local resource: C:/Users/Public/Pictures/5ecece06-5306-4743-a003-1590e202a000-original.jpeg
我把这些图片放进了公共文件夹,和我遇到的错误是一样的。 这是我的Web服务:

kioskHotelCode: "ABRH",
countryName:“测试”, url:null, hotelImage:“C:/Users/Public/Pictures/5ECECECE06-5306-4743-a003-1590e202a000-original.jpeg”

我还尝试添加文件://:

<img alt="here should be an image" 

这也是我的后端web服务:

@RequestMapping(value = "/sid", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE)
public ResponseEntity<byte[]> getImage() throws IOException {

    ClassPathResource imgFile = new ClassPathResource(uploadsDir);
    byte[] bytes = StreamUtils.copyToByteArray(imgFile.getInputStream());

    return ResponseEntity.ok().contentType(MediaType.IMAGE_JPEG).body(bytes);
}
@RequestMapping(value=“/sid”,method=RequestMethod.GET,products=MediaType.IMAGE\u JPEG\u value)
公共响应属性getImage()引发IOException{
ClassPathResource imgFile=新的ClassPathResource(uploadsDir);
byte[]bytes=StreamUtils.copyToByteArray(imgFile.getInputStream());
返回ResponseEntity.ok().contentType(MediaType.IMAGE_JPEG).body(字节);
}
但这是同样的错误,我正在用谷歌chrome进行测试,没有找到解决方案。我的问题是解决这个问题最好的方法是什么?我应该把动态图像放在哪里(我的意思是用户可以更改它)


谢谢您的帮助。

您不应该使用本地映像,因为当您发布应用程序时,其他浏览器客户端无法看到此映像。
试试这个

把你的图像放在SpringWebApp的上下文路径中,然后从那个位置检索它

如果图像处于以下状态:
WEB-INF/IMG/image.jpg

您可以通过以下方式检索它:
IMG/image.jpg

如果要使其动态化,相同的位置也可以