熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

Java防止浏覽器直接打開下載的文件

2022-06-13   來源: Java核心技術 

  這個其實是在webxml文件中配置mime下載文件類型就可以了配置的示例

  <mimemapping>

  <extension>doc</extension>

  <mimetype>application/msword</mimetype>

  </mimemapping>

  <mimemapping>

  <extension>xls</extension>

  <mimetype>application/msexcel</mimetype>

  </mimemapping>

  <mimemapping>

  <extension>pdf</extension>

  <mimetype>application/pdf</mimetype>

  </mimemapping>

  <mimemapping>

  <extension>zip</extension>

  <mimetype>application/zip</mimetype>

  </mimemapping>

  <mimemapping>

  <extension>rar</extension>

  <mimetype>application/rar</mimetype>

  </mimemapping>

  <mimemapping>

  <extension>txt</extension>

  <mimetype>application/txt</mimetype>

  </mimemapping>

  <mimemapping>

  <extension>chm</extension>

  <mimetype>application/mshelp</mimetype>

  </mimemapping>

  這樣就可以防止在浏覽器是直接打開文件而是彈出下載框供用戶下載了


From:http://tw.wingwit.com/Article/program/Java/hx/201311/26610.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.