现在的位置: 首页 > 综合 > 正文

Iframe不能解析mht格式文件

2013年03月06日 ⁄ 综合 ⁄ 共 708字 ⁄ 字号 评论关闭

最近在项目中遇到用ntko插件生成的mht格式的文件,在Iframe中显示时,mht文件不能解析,后台编码原样输出。
<div id="showMhtDiv" style="width:100%; height:600px">
            <iframe id="showMhtIFrame" name="showMhtIFrame" frameborder="0" style="width:100%;height:100%;" src="example.mht"></iframe> 
 </div>

在客户端用浏览器打开时显示内容:

MIME-Version: 1.0 Content-Location: file:///C:/268BA210/temp.htm Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="gb2312"....
在IE浏览器下单独打开该mht文件没有问题,嵌入页面中显示如上内容。原因时浏览器再解析网页时遇到.mht格式的文件不知道如何进行解析。在web.xml中配置如下代码即可正确解析mht文件
<mime-mapping> 
<extension>mht</extension> 
<mime-type>text/x-mht</mime-type> 
</mime-mapping>
若为大格式文件时可用如下配置
<mime-mapping>  
  <extension>mht</extension>  
  <mime-type>message/rfc822</mime-type>  
</mime-mapping> 
 
 

 

抱歉!评论已关闭.