站长论坛 - 站长交流社区- SEO交流论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 93|回复: 0

[Ajax] 文件上传进度条问题,求教

[复制链接]
发表于 2018-9-27 20:32:36 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
使用的apache commons,但是上传后,前面一直阻塞,进度条不动,一直到最后上传完,进度条跳到100%。请各位大侠帮忙看看,谢谢 jsp部分:
导入路径: 123 456 789
文件
servlet部分: UpFile public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); boolean isMultipartContent = ServletFileUpload.isMultipartContent(request); if (!isMultipartContent) { return; } FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); UpFileProgressListener upFileProgressListener = new UpFileProgressListener(request); upload.setProgressListener(upFileProgressListener); // HttpSession session = request.getSession(); // session.setAttribute("UpFileProgressListener", upFileProgressListener); try { List fields = upload.parseRequest(request); Iterator it = fields.iterator(); if (!it.hasNext()) { return; } while (it.hasNext()) { FileItem fileItem = it.next(); File f = new File("e:/abc"); try { fileItem.write(f); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } catch (FileUploadException e) { out.println("Error: " + e.getMessage()); e.printStackTrace(); } } progress: public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); HttpSession session = request.getSession(true); if (session == null) { out.println("Sorry, session is null"); // just to be safe return; } String testProgressListener = (String) session.getAttribute("percentDone").toString(); if (testProgressListener == null) { out.println("Progress listener is null"); return; } out.println(testProgressListener); System.out.println(testProgressListener+"====<====<"); }
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|易采站长站 ( 蒙ICP备14002389-1号 ) |

GMT+8, 2019-11-20 01:53

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表