The Content-disposition property is used as an identification field for the download file in the rfc2616 http://www.rfc-editor.org/rfc/rfc2616.pdf Chapter 19.5 Additional In Features
Have introduction, specific introduction please see Http://www.rfc-editor.org/rfc/rfc1806.txt
The fields are described below:
Disposition: = "Content-disposition" ":"
disposition-type
* (";" Disposition-parm)
disposition-type: = " inline "
/" attachment "
/Extension-token
; values are not case-sensitive
disposition-parm: = Filename-parm/parameter
filename-parm: = "filename" "=" value;
There are two types of content-disposition properties: inline and Attachment inline: Display the contents of the file directly in the page attachment: Pop-up dialog lets users download specific examples:
Content-type:image/jpeg
content-disposition:inline;filename=hello.jpg
content-description:just a small Picture of Me
To open code within a page:
File File = new file ("Rfc1806.txt");
String filename = File.getname ();
Response.setheader ("Content-type", "Text/plain");
Response.AddHeader ("Content-disposition", "inline;filename=" + New String (Filename.getbytes (), "Utf-8"));
Response.AddHeader ("Content-length", "" "+ File.length ());
Pop-up Save box Code:
File File = new file ("Rfc1806.txt");
String filename = File.getname ();
Response.setheader ("Content-type", "Text/plain");
Response.AddHeader ("Content-disposition", "attachment;filename=" + New String (Filename.getbytes (), "Utf-8"));
Response.AddHeader ("Content-length", "" "+ File.length ());
=====================================================
Turn from: http://blog.csdn.net/androidmi/article/details/7519243