简体   繁体   English

Websphere Application Server 7中的HTTP标头Mime类型

[英]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.

相关问题 http请求超时WebSphere Application Server - http request timeout WebSphere Application Server 通过Websphere Application Server管理控制台设置HTTP请求标头 - Set http request headers via websphere application server admin console Websphere Application Server中的XAException - XAException in Websphere Application Server Java应用程序服务器如何决定在HTTP Content-type标头中发送什么字符集? - How does a Java application server decide what charset to send in the HTTP Content-type header? Websphere Application Server中需要Websphere MQ类 - Websphere MQ classes needed in Websphere Application Server IBM Websphere 7设置/添加http标头值 - IBM Websphere 7 set/add http header value 是否可以将IBM HTTP Server设置为非IBM Websphere应用程序服务器的前端,并且IBM是否支持它? - Is it possible to setup the IBM HTTP server as the front end for a non IBM Websphere application server and is it supported by IBM? 通过服务进行的Http响应发送text / html中的内容(MIME)类型,但不是application / json - Http response through service sends content (mime) type in text/html but not application/json 会话管理-Websphere Application Server - Session Management - Websphere Application Server 在WebSphere Application Server中升级JavaMail - Upgrade JavaMail in WebSphere Application Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM