http-equiv="Content-Type" 
->
http-equiv="Content-Disposition" test it

解决方案 »

  1.   

    不是要先把它收到WEB-SERVER上的临时目录里,然后提供下载。}else if(message[i].isMimeType("multipart/*")){
                    Multipart mp = (Multipart)message[i].getContent();
                    int mpcount = mp.getCount();
                    Part part = mp.getBodyPart(0);
                    xxnr = (String)part.getContent();
                    //附件
                    try {
                      for (int k = 1; k < mpcount; k ++) {
                        Part part1=mp.getBodyPart(k);
                        String fjName = this.encode(part1.getFileName());//得到中文附件名
                        int fjSize = part1.getSize();//附件大小                    //附件路径
                        File fx = null;                    File fl = new File(filepath);
                        if (fl.exists()==false) fl.mkdir();                    this.saveFile(fjName,part1.getInputStream(),filepath);
                      }
                    }catch(Exception e) {
                      System.out.println(e);
                    }
                  }-----------------------
      public static String encode(String UnCharset){
        if (UnCharset == null) return null;
        String charset = null;
        try{
          byte strtemp[] = UnCharset.getBytes("ISO8859_1");
          charset = new String(strtemp);
        }catch(UnsupportedEncodingException _ex){
          System.out.println("Encode ISO8859_1 Err:" + _ex);
        }
        return charset;
      }
      //保存附件
      public static void saveFile(String filename,InputStream input,String path)throws IOException{
        if(filename==null){
          filename=File.createTempFile("xx","out").getName();
        }
        File file = new File( path  + filename);
        for(int i=0;file.exists();i++){
          file=new File(filename+i);
        }
        FileOutputStream fos=new FileOutputStream(file);
        BufferedOutputStream bos=new BufferedOutputStream(fos);
        BufferedInputStream bis=new BufferedInputStream(input);
        int aByte;
        while((aByte=bis.read())!=-1){
          bos.write(aByte);
        }
        bos.flush();
        bos.close();
        bis.close();
      }
      

  2.   

    这样附件就存到WEB-SERVER上了。然后提供输出附件或者给用户连接。
    但是要安全验证的话,给连接的方法不好,最好放到WEB方式无法直接访问的目录。