我已经在web.xml里面配置了mime-type类型,为什么文件下载打开的时候还是调用本地软件打开,不在ie里打开呢?
在另外一个系统用的没问题
源代码:
Stmt = conn.prepareStatement("SELECT fileName,upFile FROM BFile WHERE fileID=" + sFileID);
rs = util.getResult(conn, Stmt);
if (rs.next()) {
response.reset();
sFileName = new String(rs.getString("fileName").getBytes("GBK"),"ISO8859-1");
response.setHeader("Content-disposition","attachment; filename=" + sFileName);
ServletOutputStream sos = response.getOutputStream();
blob = (Blob) rs.getBlob("upFile");
InputStream pi = blob.getBinaryStream();
int blobsize = (int)blob.length();
byte[] blobbytes = new byte[blobsize];
int bytesRead = 0;
while ((bytesRead = pi.read(blobbytes)) != -1) {
sos.write(blobbytes, 0, bytesRead);
}
pi.close();
sos.flush();
}
else {
out.println("\u5BF9\u4E0D\u8D77\uFF0C\u672A\u627E\u5230\u6307\u5B9A\u6587\u4EF6\uFF01");
}
在另外一个系统用的没问题
源代码:
Stmt = conn.prepareStatement("SELECT fileName,upFile FROM BFile WHERE fileID=" + sFileID);
rs = util.getResult(conn, Stmt);
if (rs.next()) {
response.reset();
sFileName = new String(rs.getString("fileName").getBytes("GBK"),"ISO8859-1");
response.setHeader("Content-disposition","attachment; filename=" + sFileName);
ServletOutputStream sos = response.getOutputStream();
blob = (Blob) rs.getBlob("upFile");
InputStream pi = blob.getBinaryStream();
int blobsize = (int)blob.length();
byte[] blobbytes = new byte[blobsize];
int bytesRead = 0;
while ((bytesRead = pi.read(blobbytes)) != -1) {
sos.write(blobbytes, 0, bytesRead);
}
pi.close();
sos.flush();
}
else {
out.println("\u5BF9\u4E0D\u8D77\uFF0C\u672A\u627E\u5230\u6307\u5B9A\u6587\u4EF6\uFF01");
}
解决方案 »
- ajax 异步检测用户名是否存在 函数没有调用啊 求大神知道
- servlet验证用户名和密码问题?不明白 为什么他总是跳过我的if(rs.next)而偏去执行else呢?为啥连个数据库就那么难呢?学习可真不容易
- 在没有人在STRUTS中使用过SMARTUPLOAD的朋友,进来看一下
- 帮帮忙啊 100求解
- JSP中的Bean问题。请高手帮忙指点。急,在线等!!!!
- 有一百万条长度为17的数字字符串,如何快速的查找到是否有某条数字串?
- 哪里有MySql的数据库驱动程序啊??
- 谁知道如何获取小数点后两位的方法
- 向高手求救,JSP程序在进行数据库查询时的条件字段的中文问题!!!
- 老大,哪里有jsp开发的在线购物程序?现在急啊!
- 一个初学的问题,希望大家帮忙,谢谢
- 下载文件的问题
<iframe src='你指定的Servlet名再加上条件'/>