你可以不可以在上传成功以后,通过jsp调用外部工具来实现自动解压?
应该是可行的,不过你必须在服务器上有解压软件。
如果你实现不了,可以到www.zhihuigu.com上求教高人!上传组件目前多采用3种:(1)smartupload (2)oreilly upload (3) struts upload就本人的使用经历,感觉struts的上传相对来说是最简单的了。编程快乐,请访问www.zhihuigu.com,程序员俱乐部网站,讨论技术和学习感受!

解决方案 »

  1.   

    我遇到过类似问题,用jspsmart上传ZIP文件,然后解压,在Thinking in java中有代码,以下是我写的解压class MyZip
    package com.ut.util;
    import java.util.*;
    import java.util.zip.*;
    import java.io.*;public class MyZip {
      private String filename;
      private String outputpath;
      public void setFilename(String filename) {
        this.filename=filename;
      }
      public void setOutputpath(String outputpath) {
        this.outputpath=outputpath;
      }
      public MyZip() {
      }
      /**
       *
       * @param filename  带路径的ZIP文件名
       * @param outputpath 解压后输出文件路径
       */
      public MyZip(String filename,String outputpath) {
        this.filename=filename;
        this.outputpath=outputpath;
      }
      /**
       * <p>解压ZIP文件
       * @return  返回解压文件名的列表数组
       * @throws IOException
       */
      public String[] unzip() throws IOException {
        if (filename==null) return null;
        if (outputpath==null) return null;
        FileInputStream f=new FileInputStream(filename);
        CheckedInputStream csum=new CheckedInputStream(f,new Adler32());
        ZipInputStream in=new ZipInputStream(new BufferedInputStream(csum));
        ZipEntry ze;
        String s=null;
        while((ze=in.getNextEntry())!=null) {
          String name=ze.getName();
          if (s==null) {
            s=name;
          }
          else {
            s=s+"@"+name;
          }
          FileOutputStream  out=new FileOutputStream(outputpath+"\\"+name);
          int x;
          while ((x=in.read())!=-1) {
             out.write(x);
          }
          out.close();
        }
        in.close();
        return s.split("@");
      }
      public static void main(String[] args) {
        MyZip zip=new MyZip("g:\\tts\\test\\aaa.zip","g:\\tts\\test\\extra\\");
        try {
          zip.unzip();
        }
        catch (Exception e) {
          e.printStackTrace();
        }
      }
    }