为什么我的项目用IE10下载多个文件只能下载一个呢?用360极速和谷歌浏览器都可以! 80
<%@pageimport="com.apexedu.sys.util.Util"%><%@pageimport="com.apexedu.framework.util....
<%@page import="com.apexedu.sys.util.Util"%>
<%@page import="com.apexedu.framework.util.DBUtil"%>
<%@page import="com.apexedu.biz.entity.TBizPxwd"%>
<%@page language="java" contentType="application/x-msdownload"
pageEncoding="UTF-8"%>
<%@page import="java.net.URLEncoder"%>
<%@ page import="java.io.*"%>
<%
response.reset();//可以加也可以不加
response.setContentType("application/x-download;charset=UTF-8");
String wid=request.getParameter("wid");
System.out.println(wid);
String sql = "select * from t_biz_pxwd where wid=?";
TBizPxwd obj = (TBizPxwd)DBUtil.queryBean(sql, TBizPxwd.class,wid);
String path = obj.getPath();
String filedownload = Util.getAppRootPath() + path;
String filedisplay = obj.getZlmc();
filedisplay = URLEncoder.encode(filedisplay, "UTF-8");
response.addHeader("Content-Disposition", "attachment;filename="
+ filedisplay);
java.io.OutputStream outp = null;
java.io.FileInputStream in = null;
try {
outp = response.getOutputStream();
in = new FileInputStream(filedownload);
byte[] b = new byte[1024];
int i = 0;
while ((i = in.read(b)) > 0) {
outp.write(b, 0, i);
}
//
outp.flush();
//要加以下两句话,否则会报错
//java.lang.IllegalStateException: getOutputStream() has already been called for //this response
out.clear();
out = pageContext.pushBody();
} catch (Exception e) {
} finally {
if (in != null) {
in.close();
in = null;
}
DBUtil.executeSQL("update t_biz_pxwd set xzcs=xzcs+1 where wid=?", wid);
}
%> 展开
<%@page import="com.apexedu.framework.util.DBUtil"%>
<%@page import="com.apexedu.biz.entity.TBizPxwd"%>
<%@page language="java" contentType="application/x-msdownload"
pageEncoding="UTF-8"%>
<%@page import="java.net.URLEncoder"%>
<%@ page import="java.io.*"%>
<%
response.reset();//可以加也可以不加
response.setContentType("application/x-download;charset=UTF-8");
String wid=request.getParameter("wid");
System.out.println(wid);
String sql = "select * from t_biz_pxwd where wid=?";
TBizPxwd obj = (TBizPxwd)DBUtil.queryBean(sql, TBizPxwd.class,wid);
String path = obj.getPath();
String filedownload = Util.getAppRootPath() + path;
String filedisplay = obj.getZlmc();
filedisplay = URLEncoder.encode(filedisplay, "UTF-8");
response.addHeader("Content-Disposition", "attachment;filename="
+ filedisplay);
java.io.OutputStream outp = null;
java.io.FileInputStream in = null;
try {
outp = response.getOutputStream();
in = new FileInputStream(filedownload);
byte[] b = new byte[1024];
int i = 0;
while ((i = in.read(b)) > 0) {
outp.write(b, 0, i);
}
//
outp.flush();
//要加以下两句话,否则会报错
//java.lang.IllegalStateException: getOutputStream() has already been called for //this response
out.clear();
out = pageContext.pushBody();
} catch (Exception e) {
} finally {
if (in != null) {
in.close();
in = null;
}
DBUtil.executeSQL("update t_biz_pxwd set xzcs=xzcs+1 where wid=?", wid);
}
%> 展开
1个回答
展开全部
这样的情况应当是代码问题,建议更换代码
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询