解决方案 »

  1.   

    上传代码貌似逻辑错误,你每次只上传了一部分字节。
    应该这样:
    InputStream is=item.getInputStream();
                        int buffer=1024;     //定义缓冲区的大小
                        int length=0;
                        byte[] b=new byte[buffer];
                        double percent=0;
                        FileOutputStream fos=new FileOutputStream(file);
                        while((length=is.read(b))!=-1){
                            percent+=length/(double)upFileSize*100D;        //计算上传文件的百分比
                             fos.write(b,0,length);                      //向文件输出流写读取的数据
                            session.setAttribute("progressBar",Math.round(percent));    //将上传百分比保存到Session中
                        }
    参考下这个:
    JAVA上传源代码