java - 图像未显示在图像视图中,而在邮递员中它运行良好
问题描述
我真的很困惑在ImageView
. 实际上,当我URL
在邮递员中点击我的 URL 时,我得到了一个文件和另一件事,它运行良好。当我尝试使用Glide
和其他类似的东西时,Picasso
我没有从服务器获取图像。
请建议我可以为它做些什么。
我在 java 中的服务器代码在这里你也可以检查它。
@RequestMapping(value = "downloadBlog", method = RequestMethod.GET)
public ResponseEntity<?> downloadBlogImage(@RequestParam(value = "id", required = false) Long id) {
StayHealthyBlog dbFile = checkUserService.findBlogById(id);
return ResponseEntity.ok().contentType(MediaType.parseMediaType(dbFile.getImageType()))
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"xyz" + "\"")
.body(new ByteArrayResource(dbFile.getImageData()));
}
现在我怎么能得到我的形象..
提前致谢。
解决方案
替换这一行:
@RequestMapping(value = "downloadBlog", method = RequestMethod.GET)
和:
@RequestMapping(value = "downloadBlog", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE)
更新
确保 URL以http://
forGlide
或Picasso
识别链接协议开头。
Picasso.get().load("http://" + url).into(imageView); // If server return url without `http{s}://`
推荐阅读
- python - Pandas DataFrames 为特定列值添加方括号
- docker - Hyperledger Peer 容器出现故障的一些原因是什么?
- android - 在 CollapsingToolbarLayout 上覆盖 NestedScrollView
- java - Spring boot @DateTimeFormat 上所需的查询参数
- python - 如何将 PaymentMethod 附加到 DjStripe 中的条带客户?
- python - 如何使用opencv计算轮廓的厚度/如何计算对象的宽度
- javascript - 函数作为 React 子级无效。如果您返回 Component 而不是
从渲染。如何解决这个问题 - javascript - react native:如何在日历中的每一天添加背景图片?
- flutter - 如何加快 InkWell 的 splashColor 在颤动中的时间?
- web-scraping - python中是否有任何功能可以单击链接以打开和提取电子邮件?