当前位置: 代码迷 >> Java Web开发 >> java下载文件代码 兼容ie8,该如何处理
  详细解决方案

java下载文件代码 兼容ie8,该如何处理

热度:24   发布时间:2016-04-16 22:04:16.0
java下载文件代码 兼容ie8

这是一个下载服务器上文件的方法,在ie9 和其他浏览器都好用,但是ie8却不行,想问下大神们,我要怎样改能兼容ie8,或者有其他兼容ie8的下载方法
------解决方案--------------------
报什么错误呢。
------解决方案--------------------
IE8有没在工具栏底下弹出横幅提示下载之类的,点了就刷新了那种。
------解决方案--------------------
是不是 ie 的问题。ie8 重新下载测试呢。
------解决方案--------------------
应该是IE的问题。你选择工具——Internet选项——安全——可信站点——自定义级别——找到“下载”选项——都将“禁用”改为“启用”
------解决方案--------------------
我自己写的下载插件的代码,IE7-10都测试了,

public class LoadFile extends HttpServlet{
 public void doGet(HttpServletRequest request,HttpServletResponse response)
   throws IOException,ServletException{
    OutputStream o=response.getOutputStream();
    byte b[]=new byte[1024];
    //the file to download.
    File fileLoad=new File("D:\\download","MRVInst.exe");
    //the dialogbox of download file.
    response.setHeader("Content-disposition",
      "attachment;filename="+"MRVInst.exe");
    //set the MIME type.
    response.setContentType("application/application/octet-stream bin");
    //get the file length.
    long fileLength=fileLoad.length();
    String length=String.valueOf(fileLength);
    response.setHeader("Content_Length",length);
    //download the file.
    FileInputStream in=new FileInputStream(fileLoad);
    int n=0;
    while((n=in.read(b))!=-1){
     o.write(b,0,n);

    }
 }
 public void doPost(HttpServletRequest request,HttpServletResponse response)
 throws IOException,ServletException{
  doGet(request,response);
 }

}
------解决方案--------------------
引用:
Quote: 引用:

报什么错误呢。

不报错误,和别的浏览器一样 用debug追踪一下 也是该走的都走了  只是在别的浏览器弹出下载框的时候,ie8的窗口一闪而过。。。

java代码没有IE兼容性的问题,你换台电脑下载试试。
------解决方案--------------------
是不是可以修改IE内核呢?你查查
  相关解决方案