標籤:tomcat mime
Tomcat安裝完成之後預設可以開啟index.jsp檔案、但是如果你訪問index.html會顯示空白頁、原因是:在$tomcat/conf/web.xml設定檔裡、指定了什麼類型的檔案調用什麼程式開啟、但是預設沒有配置html或htm、所以我們要手動加上就可以了、以此類推、doc、war、ppt等都是一樣的方法。
[[email protected] ~]vim $tomcat/conf/web.xml
........................................................
<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>
........................................................
此段代碼可以加在任意位置、重啟後生效、:
650) this.width=650;" src="http://s5.51cto.com/wyfs02/M01/76/E4/wKiom1ZehtGwu-AuAAB_OaZiBsk645.png" title="1.png" alt="wKiom1ZehtGwu-AuAAB_OaZiBsk645.png" />
常用的檔案類型:
<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>
其他常見的MIME類型:
超文字標記語言 (HTML)文本 .htm,.html text/html
普通文本 .txt text/plain
RTF文本 .rtf application/rtf
GIF圖形 .gif image/gif
JPEG圖形 .ipeg,.jpg image/jpeg
au音效檔 .au audio/basic
MIDI音樂檔案 mid,.midi audio/midi,audio/x-midi
RealAudio音樂檔案 .ra, .ram audio/x-pn-realaudio
MPEG檔案 .mpg,.mpeg video/mpeg
AVI檔案 .avi video/x-msvideo
GZIP檔案 .gz application/x-gzip
TAR檔案 .tar application/x-
本文出自 “菜鳥的成長之路” 部落格,請務必保留此出處http://francis905.blog.51cto.com/3048056/1718824
tomcat配置<mime-mapping> 實現自動匹配檔案類型html等