zoukankan
html css js c++ java
JSP流的方式下载文件
<%
@ page
import
=
"
java.io.*
"
%>
<%
//
example:
//
<a href="download.JSP?path=img/&name=test.gif">download image</a>
String root
=
getServletContext().getRealPath(
"
/
"
);
String path
=
request.getParameter(
"
path
"
);
String name
=
request.getParameter(
"
name
"
);
System.out.println(root
+
path
+
name);
response.setContentType(
"
unknown
"
);
response.addHeader(
"
Content-Disposition
"
,
"
attachment;filename=\
""
+ name +
"
\
""
);
try
{
out.clear();
out
=
pageContext.pushBody();
OutputStream os
=
response.getOutputStream();
FileInputStream fis
=
new
java.io.FileInputStream(root
+
path
+
name);
byte
[] b
=
new
byte
[
1024
];
int
i
=
0
;
while
( (i
=
fis.read(b))
>
0
)
{
os.write(b,
0
, i);
}
fis.close();
os.flush();
os.close();
}
catch
( Exception e )
{
}
%>
查看全文
相关阅读:
H5 WebSocket
JS call()、apply()、bind()
JS中this指向问题
JS GET POST请求
php 常用get post http请求
php 开启redis
egret接入华为快应用6004
PHP生成公私钥,签名和验签
JS数组去重
Oracle第九课
原文地址:https://www.cnblogs.com/ding0910/p/1207318.html
最新文章
第08组 Beta版本演示
第08组 Beta冲刺(4/4)
第08组 Beta冲刺(3/4)
第08组 Beta冲刺(2/4)
第08组 Beta冲刺(1/4)
第08组 Alpha事后诸葛亮
第08组 Alpha冲刺(4/4)
第08组 Alpha冲刺(3/4)
第08组 Alpha冲刺(2/4)
常见的内存错误及其对策
热门文章
为什么++i比i++更优更快
[栈/STL] 简易计算器
【C++】ACboy needs your help again!
约瑟夫环问题(c语言) by链表
C/C++ bug记录
Java草稿[乱写]
[转载][python]bilibili弹幕发送者查询器软件 开发背景/思路/心得
C++ STL 笔记
c++入门学习草稿【持续更新中..】
npm notice created a lockfile as package-lock.json. You should commit this file.
Copyright © 2011-2022 走看看