求下载部分的servlet代码,OutputStream   out   =   null;   
    //  String   filename=request.getParameter("filename");   
      FileInputStream   fileInputStream   =   null;   
      try   {   
        //设置响应头和下载保存的文件名   
        response.setContentType("APPLICATION/OCTET-STREAM");   
        response.setHeader("Content-Disposition","attachment;   filename=\""   +   filename   +   "\"");   
    
      //打开指定文件的流信息   
      out   =   response.getOutputStream();   
      fileInputStream   =   new   java.io.FileInputStream(filePath);   
      byte[]   buffer   =   new   byte[65535];   
    
      //写出流信息   
      int   k;   
      while   ((k=fileInputStream.read(buffer,0,65535))   !=   -1)     
      {   
  out.write(buffer,0,k);   
      }   
        }     
  catch   (FileNotFoundException   e)   
        {  
   e.printStackTrace();
   System.out.println("下载失败");
        }   上面的这种写法,文件路径好像要给成绝对的,不是相对路径。
还有上传文件的时候,好像不能上传超过10M?
factory.setSizeThreshold(10 * 10 * 1024);
这句不起作用。

解决方案 »

  1.   

    DiskFileUpload upload = new DiskFileUpload();
       //应该还有个file thread hole
       //这个是buffer size?
    upload.setSizeMax(-1);
       //保存的临时路径?
    upload.setRepositoryPath(currentPath);
      

  2.   

    DiskFileUpload好像过时了。
    setSizeThreshold好像是设置缓冲区大小
      

  3.   

    上传文件大小限制是这个
    FileUpload upload = new FileUpload(factory);
    upload.setFileSizeMax(MAX_SIZE);