我在JSP页面中写了一段java代码用于读取数据库数据并将数据写入dbf文件中,然后把dbf文件打包并提供下载的功能,但是该代码执行的时候在IE8中可以实现下载,但是在360浏览器中弹出下载框,你点击下载后就永远处于下载状态,文件下不下来...以下是代码片段, 谢谢了...
try{ JDBField[] field = new JDBField[8]; field[0] = new JDBField("KSH",'C',14,0); field[1] = new JDBField("XM",'C',64,0); field[2] = new JDBField("KSZTMC",'C',32,0); field[3] = new JDBField("YXMC",'C',64,0); field[4] = new JDBField("PCMC",'C',16,0); field[5] = new JDBField("KLMC",'C',16,0); field[6] = new JDBField("ZYMC",'C',64,0); field[7] = new JDBField("TDYYMC",'C',253,0); DbfOutputStream dbfbytes= new DbfOutputStream(); response.reset(); response.setContentType("application/octet-stream;charset=gb18030"); String s = "attachment; filename=zyk_"+user.getName()+"_"+zzdm+".zip"; response.setHeader("Content-Disposition", s); DBFWriter dbf = new DBFWriter(dbfbytes,field); ZResultSet rst = (ZResultSet)rm.getData(); Vector<Vector> datas = rst.getDatas(); for (int i=0;i<datas.size();i++){ Vector row = datas.get(i); Object[] rows = {row.get(0).toString(),row.get(1),row.get(2),row.get(3),row.get(4),row.get(5),row.get(6),row.get(7)}; dbf.addRecord(rows); } dbf.close(); dbfbytes.getBytes()[4] = dbfbytes.int2Bytes(datas.size())[3]; dbfbytes.getBytes()[5] = dbfbytes.int2Bytes(datas.size())[2]; dbfbytes.getBytes()[6] = dbfbytes.int2Bytes(datas.size())[1]; dbfbytes.getBytes()[7] = dbfbytes.int2Bytes(datas.size())[0]; java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(); java.util.zip.ZipOutputStream zip= new java.util.zip.ZipOutputStream(bos); java.util.zip.ZipEntry entry = new java.util.zip.ZipEntry(user.getName()+"_"+zzdm+".dbf"); entry.setSize(dbf.getSize()); zip.putNextEntry(entry); zip.write(dbfbytes.getBytes(),0,dbf.getSize()); zip.closeEntry(); zip.close(); byte[] buf = bos.toByteArray(); response.setHeader("Content-Length", new Integer(buf.length).toString()); response.getOutputStream().write(buf,0,buf.length); response.getOutputStream().close(); }catch(Exception ex ){ out.println(ex.getMessage()); }