如何在 Content-Disposition 标头中设置包含空格的文件名 [英] How to set filename containing spaces in Content-Disposition header

查看:46
本文介绍了如何在 Content-Disposition 标头中设置包含空格的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码:

resp.addHeader("Content-Disposition", "inline; filename=" + fileName);

当文件名为a_b_c.doc"或abc.doc"时,下载文件的名称显示正确.但是,当文件名为a b c .doc"时,下载文件的名称仅为a".

When the file name is "a_b_c.doc" or "abc.doc" the name of the downloaded file is displayed correctly. However, when the file name is "a b c .doc" the name of the downloaded file is only "a".

我们如何解决这个问题?

How can we solve this?

推荐答案

使用引号:

resp.addHeader("Content-Disposition", "inline; filename="" + fileName + """);

这篇关于如何在 Content-Disposition 标头中设置包含空格的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆