Download1the. Download is the response to the client byte data! It turns out that we're all responding to HTML character data! Turn a file into a byte array, use Response.getoutputstream () to each browser!!! 2. Requirements for download*two heads a stream! > Content-type: What MIME type is the file you pass to the client, for example: image/Pjpeg*Call ServletContext's GetMimeType () method with the file name to get the MIME type! > content-disposition: Its default value is inline, which means it opens in a browser window! Attachment;filename=XXX* in Filename=followed by the file name that appears in the Download box! >Stream: The file data to download! *your own new one input stream can! ---------------------------Download the details1when the Chinese name appears in the download box, garbled characters appear. *firefox:base64 encoding. *Most other browsers: URL encoding. General scenario: FileName=NewString (Filename.getbytes ("GBK"), "Iso-8859-1"); Public StaticString filenameencoding (string filename, httpservletrequest request)throwsIOException {String Agent= Request.getheader ("user-agent");//Get Browser if(Agent.contains ("Firefox") {Base64encoder Base64encoder=NewBase64encoder (); FileName= "=?utf-8?" B? " + Base64encoder.encode (filename.getbytes ("Utf-8")) + "?="; } Else if(Agent.contains ("MSIE") ) {filename= Urlencoder.encode (filename, "Utf-8"); } Else{filename= Urlencoder.encode (filename, "Utf-8"); } returnfilename; }------------------------------------------------------
Upload Download---Download