web.xml 中 mime-mapping的使用

[size=medium] mime-mapping  如果Web应用程序包含一些不常用的文件,则需要确保分配某些MIME类型,mime-mapping元素正是为此而设计的。

添加rar,iso等的mime-type映射,避免在浏览器里直接打开。

如:
<mime-mapping>
<extension>rar</extension>
<mime-type>application/x-download</mime-type>
</mime-mapping>

 

 <!-- 更多示例:-->

 <mime-mapping> 
<extension>mht</extension> 
<mime-type>text/x-mht</mime-type> 
</mime-mapping> 
<mime-mapping> 
        <extension>rar</extension> 
        <mime-type>application/octet-stream</mime-type> 
    </mime-mapping> 
    <mime-mapping> 
        <extension>iso</extension> 
        <mime-type>application/octet-stream</mime-type> 
    </mime-mapping> 
    <mime-mapping> 
        <extension>ape</extension> 
        <mime-type>application/octet-stream</mime-type> 
    </mime-mapping> 
    <mime-mapping> 
        <extension>rmvb</extension> 
        <mime-type>application/octet-stream</mime-type> 
    </mime-mapping> 
    <mime-mapping> 
        <extension>ico</extension> 
        <mime-type>image/x-icon</mime-type> 
    </mime-mapping>  


   <mime-mapping> 
   <extension>doc</extension>    
<mime-type>application/msword</mime-type>    
</mime-mapping>    
<mime-mapping>    
   <extension>xls</extension>    
   <mime-type>application/vnd.ms-excel</mime-type>    
</mime-mapping>    
<mime-mapping>    
   <extension>ppt</extension>    
   <mime-type>application/vnd.ms-powerpoint</mime-type>    
</mime-mapping> 


 <!--  修改下面两行以支持静态超文本的自动编码   
  -->   
 <mime-mapping>  
  <extension>htm</extension>   
  <mime-type>text/html;charset=gb2312</mime-type>   
  </mime-mapping>  
 <mime-mapping>  
  <extension>html</extension>   
  <mime-type>text/html;charset=gb2312</mime-type>   
  </mime-mapping>

[/size]

你可能感兴趣的:(html,xml,Web,浏览器,Excel)