没试过,
友情Up 将“流氓无赖”测试到底
——始于2003年7月
树欲止而风不停,行云流水匆匆去;
树梢蚂蚱凭空望,江边浪花碎巨石; 支持“流金岁月”!!!
——2003年12月24日am^@^

解决方案 »

  1.   

    //下载
      
      public String getdocumentomage(String id, String path) {    if (id == null || id.equals("")) {
          return "null";
        }
        File f = new File(path);
        if (f.exists()) {
          return "exists";
        }
        String sql = "";    sql = "select * from TB_IMAGE WHERE document_image_id=" + id;
        try {
          Statement pstmt;
          pstmt = con.createStatement();
          ResultSet rr = pstmt.executeQuery(sql);
          if (rr.next()) {
            byte[] img = rr.getBytes("CONTENT");
            File ff = new File(path);
            try {
              FileOutputStream out = new FileOutputStream(ff);
              out.write(img);
              out.close();
            }
            catch (java.io.FileNotFoundException e1) {
              path = "file not found:" + e1.getMessage();
            }
          }
          rr.close();
          pstmt.close();
          return path;
        }
        catch (Exception e) {
          return "error";
        }
      }//下载附件调用上边bean
       rs=op.getdb("select * from tb_image where document_id);
    while(rs.next())
    { String documentimageid=rs.getString("document_image_id");
     String url=rs.getString("url").trim();
     String  title2=rs.getString("title");
             String srcpath=request.getContextPath()+documentimageid+url;
    String realpath=request.getRealPath(documentimageid+url);
    String slt=op.getdocumentomage(documentimageid,realpath);//创建文件
    }
      

  2.   

    楼主:如果附件为中文时会出错,英文不会,等待解决;如果附件大小为0k时会出错,
    加一个判断: 
            int chunk = part.getSize();
            if (chunk<0)//如果附件大小为空则为0
               chunk=0;
            byte[] buffer = new byte[chunk];
      

  3.   

    楼主:如果附件名称为中文时会出错,英文不会,等待解决;如果附件大小为0k时会出错,
    加一个判断: 
            int chunk = part.getSize();
            if (chunk<0)//如果附件大小为空则为0
               chunk=0;
            byte[] buffer = new byte[chunk];