日期:2014-05-20  浏览次数:20904 次

下载exceL被IE阻止了。怎么解决啊?
大致的前后我贴下代码,大家指导一下
$.ajax({
url:"./login.wf?sid="+sid+"&cmd=Ghs_To_Download&leimuid="+leimuId,
data:{leimuid:leimuId},
success:function(response,options){    
 window.location.href ="../receive_upload.type=download";
}
}
});
我url的请求的是动态生成excel,window.location.href到了jsp页面,jsp上面处理的下载

response.reset();
        response.setContentType("APPLICATION/OCTET-STREAM");
        filePath = response.encodeURL(new String(filePath.getBytes(),
                "ISO8859_1"));
        response.setHeader("Content-Disposition", "attachment; filename=\""
                + filePath + "\"");
        response.setContentType("application/octet-stream;"); 
        OutputStream outs = response.getOutputStream();
        InputStream inStream = new FileInputStream(filePath);
        byte[] b = new byte[1024];
        int len;
        while ((len = inStream.read(b)) > 0)
            outs.write(b, 0, len);
        response.setStatus(response.SC_OK);
        response.flushBuffer();
        outs.close();
        outs.flush();
        inStream.close();  

但是下载总是被IE阻止,要点IE的下载文件,刷新一次页面后才能下载 

------解决方案--------------------
用window.open()来打开下载的页面