【问题标题】:Determine image name from dynamically created URL从动态创建的 URL 确定图像名称
【发布时间】:2014-10-22 21:44:15
【问题描述】:

我正在使用 Liferay 6.1。我的问题是,当我使用 Liferay 标签创建 url 时,浏览器似乎无法正确确定文件名。例如,在<img> 标签src 属性中使用下面的 url 会导致图像被命名为“images”,当文件被保存时,新文件的名称是 images.jpg 而不是 imageId123.jpg

http://example.com/images?p_p_id=imagesdisplay_WAR_imagesportlet&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_cacheability=cacheLevelPage&_imagesdisplay_WAR_imagesportlet_struts.portlet.action=%2Fview%2FgetWmarkedImage&imageId=imageId123

我需要图像名称为 imageId123,以便在保存时它会有一个文件名,例如 imageId123.jpg。有没有办法在电脑上保存图片时指定图片名或下载的文件名?

【问题讨论】:

    标签: java html image liferay


    【解决方案1】:

    您不得通过下载文件名进行操作。

    改用content-disposition 标头。

    responseFile.setContentType("application/x-download");
    responseFile.setHeader("Content-disposition", "attachment; filename=imageId123");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-30
      • 2019-12-05
      • 2012-09-30
      • 2015-01-20
      • 1970-01-01
      • 2017-11-05
      • 2011-12-07
      • 1970-01-01
      相关资源
      最近更新 更多