文件下载问题,点击下载可以弹出保存框,选择保存文件 急 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <%@ page language="java" import="java.sql.*" import="com.jspsmart.upload.*"import="java.lang.*" %><jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" /><%String sUrl="";String sfilename="";String path = request.getParameter("path");SmartUpload su = new SmartUpload(); // 上传初始化 su.initialize(pageContext); su.setContentDisposition(null);// 下载文件sfilename=path; //FileName是数据库中的一项 sUrl = sfilename; su.downloadFile(sUrl); %> String path="c:/"; String fname = "test.txt";//文件名FileInputStream fis=new FileInputStream(path+fname); OutputStream os = response.getOutputStream();//取得输出流 response.reset();//清空输出流 response.setHeader("Content-disposition", "attachment; filename=" + fname );//设定输出文件头 response.setContentType("application/file");//定义输出类型byte[] mybyte=new byte[8192];int len=0;while((len=fis.read(mybyte))!=-1) { os.write(mybyte,0,len);}os.flush();fis.close();os.close(); jsp中请求转发 链接请求 和表单提交的问题 为什么用hashmap作为返回值,接收到的一直为空? jquery load head静态显示不了 请问怎么翻译cookie里的信息 那个web上分页怎么弄啊? 求一个MYSQL 自动备份的脚本? 急问!!!!!!来者有分 关于运行如何JSP程序的简单问题。 关于jbulider9 servlet&javabean的配置问题 关于jsp文件的位置问题? XML简单问题 一段简单的js出错???????
import="java.lang.*" %>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<%
String sUrl="";
String sfilename="";
String path = request.getParameter("path");SmartUpload su = new SmartUpload();
// 上传初始化
su.initialize(pageContext);
su.setContentDisposition(null);
// 下载文件sfilename=path; //FileName是数据库中的一项
sUrl = sfilename;
su.downloadFile(sUrl);
%>
String fname = "test.txt";//文件名
FileInputStream fis=new FileInputStream(path+fname);
OutputStream os = response.getOutputStream();//取得输出流
response.reset();//清空输出流
response.setHeader("Content-disposition", "attachment; filename=" + fname );//设定输出文件头
response.setContentType("application/file");//定义输出类型
byte[] mybyte=new byte[8192];
int len=0;
while((len=fis.read(mybyte))!=-1) {
os.write(mybyte,0,len);
}
os.flush();
fis.close();
os.close();