Websphere Application Server 7中的HTTP标头Mime类型 [英] HTTP Header Mime Type in Websphere Application Server 7
问题描述
我有一个Spring Web应用程序,用户可以在其中下载PDF和Excel文件。我为它们设置了HTTP标头:
I have a Spring Web Application where a user can download PDF and Excel Files. I set the HTTP header for both of them:
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentType(MediaType.parseMediaType("application/vnd.ms-excel"));
responseHeaders.setContentLength(fileSize);
responseHeaders.set("Content-Disposition", "attachment");
responseHeaders.add("Content-Disposition", "filename=\"" + encodedFileName + '\"');
这在Tomcat上运行正常(HTTP响应是mime类型application / vnd.ms-excel) 。
但是在Websphere 7上,服务器总是为此请求返回内容类型:text / html。
This works fine on Tomcat (the HTTP response is of mime type application/vnd.ms-excel). But on Websphere 7, the server always return content type: text/html for this request.
我已经注册了excel内容类型网络领域虚拟主机,但这不会改变任何东西。
我错过了什么?
推荐答案
您的语法不正确,您不能拥有多个CD标头。像这样:
Your syntax is incorrect, you can't have multiple C-D headers. Like this:
responseHeaders.set("Content-Disposition", "attachment; filename=\"" + encodedFileName + '\"');
此外,当encodedFilenName包含ISO-8859-1字符集之外的字符时,代码将无法正常工作。
Also, the code will not work correctly when encodedFilenName contains characters outside the ISO-8859-1 character set.
(不管这是否与你的问题有关)
(dunno whether that's related to your problem, though)
这篇关于Websphere Application Server 7中的HTTP标头Mime类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!