Contentt-Displationレスポンスヘッダは、ブラウザでファイルを開くかダウンロードするかを設定します.
2232 ワード
Conttentt-Dispopsition属性は、ダウンロードファイルの識別フィールドとして、rfc 2616にあります. http://www.rfc-editor.org/rfc/rfc2616.pdf チャプター19.5 Additional Feature中
紹介があります.具体的に紹介してください. http://www.rfc-editor.org/rfc/rfc1806.txt
フィールドの紹介は以下の通りです.
inline:ファイルの内容を直接ページに表示します.
atechment:ポップアップダイアログを使用者にダウンロードさせる
紹介があります.具体的に紹介してください. http://www.rfc-editor.org/rfc/rfc1806.txt
フィールドの紹介は以下の通りです.
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;
Contentt-Dispposition属性は2種類あります.inlineとatachment.inline:ファイルの内容を直接ページに表示します.
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());
atechment:ポップアップダイアログを使用者にダウンロードさせる
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());