java web开发在web.xml配置实现浏览器根据文件类型自动打开

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

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

 

 

Xml代码   收藏代码
  1. <mime-mapping>  
  2.     <extension>docextension>  
  3.     <mime-type>application/vnd.ms-wordmime-type>  
  4. mime-mapping>  
  5. <mime-mapping>  
  6.     <extension>gifextension>  
  7.     <mime-type>image/gifmime-type>  
  8. mime-mapping>  
  9. <mime-mapping>  
  10.     <extension>htmextension>  
  11.     <mime-type>text/htmlmime-type>  
  12. mime-mapping>  
  13. <mime-mapping>  
  14.     <extension>htmlextension>  
  15.     <mime-type>text/htmlmime-type>  
  16. mime-mapping>  
  17. <mime-mapping>  
  18.     <extension>jnlpextension>  
  19.     <mime-type>application/x-java-jnlp-filemime-type>  
  20. mime-mapping>  
  21. <mime-mapping>  
  22.     <extension>jpegextension>  
  23.     <mime-type>image/jpegmime-type>  
  24. mime-mapping>  
  25. <mime-mapping>  
  26.     <extension>jpgextension>  
  27.     <mime-type>image/jpegmime-type>  
  28. mime-mapping>  
  29. <mime-mapping>  
  30.     <extension>jsextension>  
  31.     <mime-type>application/x-javascriptmime-type>  
  32. mime-mapping>  
  33. <mime-mapping>  
  34.     <extension>pdfextension>  
  35.     <mime-type>application/pdfmime-type>  
  36. mime-mapping>  
  37. <mime-mapping>  
  38.     <extension>pngextension>  
  39.     <mime-type>image/pngmime-type>  
  40. mime-mapping>  
  41. <mime-mapping>  
  42.     <extension>rarextension>  
  43.     <mime-type>application/x-rar-compressedmime-type>  
  44. mime-mapping>  
  45. <mime-mapping>  
  46.     <extension>txtextension>  
  47.     <mime-type>text/plainmime-type>  
  48. mime-mapping>  
  49. <mime-mapping>  
  50.     <extension>xlsextension>  
  51.     <mime-type>application/vnd.ms-excelmime-type>  
  52. mime-mapping>  
  53. <mime-mapping>  
  54.     <extension>xmlextension>  
  55.     <mime-type>text/xmlmime-type>  
  56. mime-mapping>  
  57. <mime-mapping>  
  58.     <extension>xulextension>  
  59.     <mime-type>application/vnd.mozilla.xul-xmlmime-type>  
  60. mime-mapping>  
  61. <mime-mapping>  
  62.     <extension>zhtmlextension>  
  63.     <mime-type>text/htmlmime-type>  
  64. mime-mapping>  
  65. <mime-mapping>  
  66.     <extension>zipextension>  
  67.     <mime-type>application/x-zipmime-type>  
  68. mime-mapping>  
  69. <mime-mapping>  
  70.     <extension>zulextension>  
  71.     <mime-type>text/htmlmime-type>  
  72. mime-mapping>  

你可能感兴趣的:(java web开发在web.xml配置实现浏览器根据文件类型自动打开)