JSPservlet skills highlights

xiaoxiao2021-03-06  73

1. Let the browser pop-up "Download" dialog box

<% Response.setContentType ( "APPLICATION / OCTET-STREAM"); response.setHeader ( "Content-Disposition", "attachment; filename =" strShowFile ""); java.io.FileInputStream fileInputStream = new java.io.FileInputStream (Strfile); INT i; while ((i = fileInputstream.read ())! = -1) {Out.write (i);} fileinputstream.close (); out.close ();%>

STRSHOWFILE is the default name to be displayed when saving files, including extensions, Strfile is the file to download, including absolute directories.

转载请注明原文地址:https://www.9cbs.com/read-88952.html

New Post(0)