使用 ResponseEntity 时,Websphere 未返回 text/html 标头,在 Tomcat 中是否有效?
您好,我有一些代码在 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 的响应标头
Via: 1.1伦德姆兹萨01 连接:保持活动状态 代理连接:保持活动状态 传输编码:分块 日期:2011 年 3 月 8 日星期二 23:28:29 GMT 内容类型:text/html;字符集=UTF-8 服务器:Apache-Coyote/1.1 保持活动:超时 = 15,最大 = 100
来自 Firebug - websphere 的响应标头
通过:1.1 RENDMZISA01 连接:保持活动状态 代理连接:保持活动状态 传输编码:分块 日期:2011 年 3 月 8 日星期二 23:22:47 GMT 内容类型:application/json;charset=UTF-8 服务器:WebSphere应用服务器/7.0 内容语言:en-AU 保持活动状态:超时 = 15,最大值 = 100
感谢任何帮助。
Hi i have some code that works fine in Tomcat, but under Websphere the response being returned does not seem to take on the Content-Type header that I am specifically setting to 'text/html'
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);
}
Response Headers from Firebug - tomcat
Via: 1.1 RENDMZISA01
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
Transfer-Encoding: chunked
Date: Tue, 08 Mar 2011 23:28:29 GMT
Content-Type: text/html; charset=UTF-8
Server: Apache-Coyote/1.1
Keep-Alive: timeout=15, max=100
Response Headers from Firebug - websphere
Via: 1.1 RENDMZISA01
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
Transfer-Encoding: chunked
Date: Tue, 08 Mar 2011 23:22:47 GMT
Content-Type: application/json;charset=UTF-8
Server: WebSphere Application Server/7.0
Content-Language: en-AU
Keep-Alive: timeout=15, max=100
Any help appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请仔细查看管理控制台。您将找到有关哑剧类型的视图。 WAS 会自动为已定义后缀的所有内容设置 mime 类型,并且附带了相当广泛的列表。这些设置可能会否决您的应用程序代码。
Please look at the Administrative Console more closely. You will find a view about mime types. WAS automatically sets mime types for everything that has defined suffixes and it ships with somewhat extensive list. These settings might overrule your application code.