繁体   English   中英

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

[英]HTTP Header Mime Type in Websphere Application Server 7

我有一个Spring Web Application,用户可以在其中下载PDF和Excel文件。 我为它们都设置了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 + '\"');

这在Tomcat上可以正常工作(HTTP响应的MIME类型为application / vnd.ms-excel)。 但是在Websphere 7上,服务器始终返回内容类型:此请求的text / html。

我已经在Web Sphere虚拟主机中注册了excel内容类型,但这并没有改变。

我错过了什么?

您的语法不正确,不能有多个CD头。 像这样:

responseHeaders.set("Content-Disposition", "attachment; filename=\"" + encodedFileName + '\"');

另外,当encodedFilenName包含ISO-8859-1字符集之​​外的字符时,该代码将无法正常工作。

(不知道这是否与您的问题有关)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM