简体   繁体   English

Internet Explorer无法打开扩展名为“ .DOC”的Microsoft Word文件

[英]Internet Explorer cant open Microsoft Word file with extension “.DOC”

My Java web application is having a document file. 我的Java Web应用程序有一个文档文件。 When I try to download the file by clicking the link It opens a new page with corrupted characters as another tab. 当我尝试通过单击链接下载文件时,它将打开一个包含损坏字符的新页面作为另一个选项卡。 When i try to save the page it saved as .htm file 当我尝试保存页面时,将其另存为.htm文件

But the file is downloaded properly in other browsers like Chrome , Firefox. 但是该文件已在其他浏览器(例如Chrome和Firefox)中正确下载。 I do a check by changing the extension from .DOC to .doc and I can able to download the file. 我通过将扩展名从.DOC更改为.doc进行检查,可以下载该文件。

Is there a particular reason that .DOC opens a corrupted page in IE. .DOC在IE中打开损坏的页面是否有特定原因。 Why it is only happening in IE 为什么只在IE中发生

I just encountered the same issue and found the cause to be a missing MIME type mapping on the application server (in my case, Tomcat). 我只是遇到了同样的问题,发现原因是应用程序服务器(在我的情况下是Tomcat)上缺少MIME类型映射。 For Tomcat, you would fix this by adding the following to conf/web.xml: 对于Tomcat,您可以通过将以下内容添加到conf / web.xml中来解决此问题:

<mime-mapping>
    <extension>doc</extension>
    <mime-type>application/msword</mime-type>
</mime-mapping>

The exact file you'd need to edit will vary, based on your application server, but a quick Google search for your AS and "mime type mapping" should tell you what you need to edit and where. 根据您的应用程序服务器,您需要编辑的确切文件会有所不同,但是Google快速搜索AS和“ MIME类型映射”将告诉您需要编辑的内容以及在何处。

I should note that older versions of Tomcat (released before Tomcat 8) are case sensitive for MIME type mappings, so if you find that .doc works but .DOC doesn't, add an additional entry to the web.xml file with DOC as the extension. 我应该注意,较早版本的Tomcat(在Tomcat 8之前发行)对于MIME类型映射区分大小写,因此,如果您发现.doc有效,但.DOC不起作用,请在web.xml文件中添加一个附加条目,其中DOC为扩展名。

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

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