刚才没搜索,我在网上找到答案了。
就是在ActionForm里设置一个FormFile类型就可以了。

解决方案 »

  1.   

    嗯,确实FormFile是apache自己封装的一个类,和struts结合确实是个好的方法
      

  2.   

    不错,不过在表单里提交文件名,action就接收一个文件名的字符串,然后业务逻辑自己去找文件不好么
      

  3.   

    在bean里的处理方法:
    1.如下定义
    private FormFile uploadFile;
    2.如下获取数据
    String fname=uploadFile.getFileName();
    InputStream ins = uploadFile.getInputStream();
    OutputStream outs=new FileOutputStream(store_path+"/"+fname);
    int bytesRead=0;
    int size=uploadFile.getFileSize();
    byte[] buffer=new byte[size];
    while((bytesRead=ins.read(buffer,0,size))!=-1){
        outs.write(buffer,0,bytesRead);
    }
    希望对你有帮助!
      

  4.   

    楼上用的是struts.upload包中的API如果是common.fileupload包的话怎么写呢?
    有没有大侠说一下?