java防止浏览器直接打开下载的文件
这个其实是在web.xml文件中配置mime下载文件类型就可以了,配置的示例:
<mime-mapping> <extension>doc</extension> <mime-type>application/msword</mime-type> </mime-mapping> <mime-mapping> <extension>xls</extension> <mime-type>application/msexcel</mime-type> </mime-mapping> <mime-mapping> <extension>pdf</extension> <mime-type>application/pdf</mime-type> </mime-mapping> <mime-mapping> <extension>zip</extension> <mime-type>application/zip</mime-type> </mime-mapping> <mime-mapping> <extension>rar</extension> <mime-type>application/rar</mime-type> </mime-mapping> <mime-mapping> <extension>txt</extension> <mime-type>application/txt</mime-type> </mime-mapping> <mime-mapping> <extension>chm</extension> <mime-type>application/mshelp</mime-type> </mime-mapping>