Content-Disposition 响应头
来源:互联网 发布:tcp socket编程 编辑:程序博客网 时间:2024/05/16 08:07
Content-Disposition 属性是作为对下载文件的一个标识字段,在rfc2616 http://www.rfc-editor.org/rfc/rfc2616.pdf 章节19.5 Additional Features中
有介绍,具体介绍请看 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;Content-Disposition属性有两种类型:inline 和 attachment inline :将文件内容直接显示在页面 attachment:弹出对话框让用户下载具体例子:
Content-Type: image/jpeg Content-Disposition: inline;filename=hello.jpg Content-Description: just a small picture of me
在页面内打开代码:
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());弹出保存框代码:
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());
- Content-Disposition 响应头
- Content-Disposition 响应头
- Content-Disposition 响应头
- Content-disposition下载头部响应
- (4)请求头:referer。响应头:状态行、refresh、Content-Disposition、页面缓存
- 设置响应头的Content-Disposition属性,实现文件下载示例
- Servlet——使用http响应头Content-Disposition下载文件的示例
- Content-Disposition 响应头,设置文件在浏览器打开还是下载
- Content-Disposition
- Content-Disposition
- Content-disposition
- Content-disposition
- Content-disposition
- Content-disposition
- Content-disposition
- Content-disposition
- Content-disposition
- Content-Disposition的作用
- power desinger使用技巧
- 注册事件,使其生效,订阅事件(VB)
- CAVLC中的前缀和后缀
- cvWaitKey
- EL表达式对字符串处理
- Content-Disposition 响应头
- 交叉编译configure命令参数小解
- 二分算法(折半算法)详解
- EditText和底部tabhost优化
- Win32 窗口
- 怀着一颗谦逊的心上路
- 浅析Java语言中两种异常的差别
- 在SQL Server Management Studio (SSMS)中使用字体颜色
- android中将静态库链接进动态库成功的例子