美文网首页
WEB.XML配置实现浏览器根据文件

WEB.XML配置实现浏览器根据文件

作者: wyatt_plus | 来源:发表于2017-09-25 15:38 被阅读0次

    我们用浏览器打开文件的时候会发现如果是doc文件, 会用记事本打开,出现乱码, 但是如果在web.xml里面配置了类型,浏览器就会根据配置的类型自动调用相应的程序打开

    在 WEB.XML 配置常用文件类型

        <mime-mapping>
            <extension>doc</extension>
            <mime-type>application/vnd.ms-word</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>gif</extension>
            <mime-type>image/gif</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>htm</extension>
            <mime-type>text/html</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>html</extension>
            <mime-type>text/html</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>jnlp</extension>
            <mime-type>application/x-java-jnlp-file</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>jpeg</extension>
            <mime-type>image/jpeg</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>jpg</extension>
            <mime-type>image/jpeg</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>js</extension>
            <mime-type>application/x-javascript</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>pdf</extension>
            <mime-type>application/pdf</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>png</extension>
            <mime-type>image/png</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>rar</extension>
            <mime-type>application/x-rar-compressed</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>txt</extension>
            <mime-type>text/plain</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>xls</extension>
            <mime-type>application/vnd.ms-excel</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>xml</extension>
            <mime-type>text/xml</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>xul</extension>
            <mime-type>application/vnd.mozilla.xul-xml</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>zhtml</extension>
            <mime-type>text/html</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>zip</extension>
            <mime-type>application/x-zip</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>zul</extension>
            <mime-type>text/html</mime-type>
        </mime-mapping>
        
    

    相关文章

      网友评论

          本文标题:WEB.XML配置实现浏览器根据文件

          本文链接:https://www.haomeiwen.com/subject/jqkdextx.html