[英]HTTP Header Mime Type in Websphere Application Server 7
I have a Spring Web Application where a user can download PDF and Excel Files. 我有一个Spring Web Application,用户可以在其中下载PDF和Excel文件。 I set the HTTP header for both of them:
我为它们都设置了HTTP标头:
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 + '\"');
This works fine on Tomcat (the HTTP response is of mime type application/vnd.ms-excel). 这在Tomcat上可以正常工作(HTTP响应的MIME类型为application / vnd.ms-excel)。 But on Websphere 7, the server always return content type: text/html for this request.
但是在Websphere 7上,服务器始终返回内容类型:此请求的text / html。
I have already registered the excel content type in the web sphere virtual host, but this does not change anything. 我已经在Web Sphere虚拟主机中注册了excel内容类型,但这并没有改变。
What did I missed? 我错过了什么?
Your syntax is incorrect, you can't have multiple CD headers. 您的语法不正确,不能有多个CD头。 Like this:
像这样:
responseHeaders.set("Content-Disposition", "attachment; filename=\"" + encodedFileName + '\"');
Also, the code will not work correctly when encodedFilenName contains characters outside the ISO-8859-1 character set. 另外,当encodedFilenName包含ISO-8859-1字符集之外的字符时,该代码将无法正常工作。
(dunno whether that's related to your problem, though) (不知道这是否与您的问题有关)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.