Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的服务调用返回图像。
它返回 png 图像,并且它的 header 中的 content-type 为 image/jpeg ,它在同一页面中打开图像。我想为用户提供将该图像保存到磁盘的选项。
您需要Content-Disposition服务器响应中的标头
Content-Disposition
例如
Content-Disposition 可以是内联的,将 content-disposition 指定为附件
response.setContentType("image/jpeg"); response.setHeader("Content-Disposition", "attachment; filename=" + imageName + ".jpg");