当前位置: 代码迷 >> Java Web开发 >> 关于下载页面的制作
  详细解决方案

关于下载页面的制作

热度:208   发布时间:2008-07-05 13:34:20.0
关于下载页面的制作
我做了个下载的界面,可是在JSP下无法显示,总是报网页无法显示,可是用servlet写了同样的代码就能通过了。不知道为什么。谁能解释下。关键部分代码如下:

             response.setContentType("application/x-zip-compressed");
        ServletOutputStream out=response.getOutputStream();
        File f=null;
        BufferedInputStream buf=null;
        try{
        f=new File("C:\\xx.zip");
        response.setContentLength((int)f.length());
        FileInputStream input=new FileInputStream(f);
        buf=new BufferedInputStream(input);
        int readBytes=0;
        while((readBytes=buf.read())!=-1)
            out.write(readBytes);
        
        }catch(Exception e){
        e.printStackTrace();
        }finally{
        if(out!=null)
            out.close();
        if(buf!=null)
            buf.close();
        }
很常见的代码,不知道问什么不行在JSP下
搜索更多相关主题的帖子: 页面  制作  

----------------解决方案--------------------------------------------------------
  相关解决方案