【问题标题】:text/html header not returned in response from Websphere when using ResponseEntity, works in Tomcat?使用 ResponseEntity 时未从 Websphere 响应中返回 text/html 标头,在 Tomcat 中有效吗?
【发布时间】:2011-07-11 13:37:43
【问题描述】:

您好,我有一些在 Tomcat 中运行良好的代码,但在 Websphere 下,返回的响应似乎没有采用我专门设置为“text/html”的 Content-Type 标头

public ResponseEntity<?>  postAttachment(@ModelAttribute AttachmentDto attachmentDto) {
  HttpHeaders responseHeaders = new HttpHeaders();
  responseHeaders.setContentType(MediaType.TEXT_HTML);
  RestResponse<AttachmentDto> response = attachmentService.save(attachmentDto); 
  return new ResponseEntity<RestResponse<AttachmentDto>>(response, responseHeaders, HttpStatus.OK);

}

来自 Firebug - tomcat 的响应标头

通过:1.1 RENDMZISA01 连接:保持活动 代理连接:保持活动 传输编码:分块 日期:格林威治标准时间 2011 年 3 月 8 日星期二 23:28:29 内容类型:text/html; charset=UTF-8 服务器:Apache-Coyote/1.1 保活:超时=15,最大值=100

来自 Firebug - websphere 的响应标头

通过:1.1 RENDMZISA01 连接:保持活动 代理连接:保持活动 传输编码:分块 日期:格林威治标准时间 2011 年 3 月 8 日星期二 23:22:47 内容类型:application/json;charset=UTF-8 服务器:WebSphere Application Server/7.0 内容语言:en-AU 保活:超时=15,最大值=100

任何帮助表示赞赏。

【问题讨论】:

  • 您是直接访问 WebSphere,还是通过 HTTP 服务器(例如 IHS)?

标签: header websphere response content-type


【解决方案1】:

请仔细查看管理控制台。您将找到有关 mime 类型的视图。 WAS 自动为已定义后缀的所有内容设置 mime 类型,并且附带了一些扩展列表。这些设置可能会否决您的应用程序代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-29
    • 2016-03-10
    • 2011-02-16
    • 1970-01-01
    • 2019-02-10
    • 1970-01-01
    • 2017-03-23
    • 1970-01-01
    相关资源
    最近更新 更多