[Struts] struts1.x下载文件完成后跳转到成功画面

看了好多网上用struts1.x实现文件下载功能的介绍了
action的写法大致有三 1, 用输入流,输出流
2, 用dispatcher
3, 用downloadAction
可是,怎么没看见个下载完成后跳转到成功画面的写法呢
用了第一和第二两种写法,最后都只能return null,如果写成return mapping.findForward("success"),则都会因为response已经提交而报exception
莫非都是下载完了就什么也不管了?
很疑惑,不知道怎么办好?有解决方法么,或者非正规的解决方法也好

[b]问题补充:[/b]

这段代码也是我从论坛上看来的,下载没有问题,画面forward不可

[code="java"]
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {

        FileDownLoadForm fdform =(FileDownLoadForm)form;
        String path = fdform.getFilePath();

        BufferedInputStream   bis = null;
        BufferedOutputStream  bos = null;
        InputStream fis = null;
        OutputStream fos = null;

        try{

            File uploadFile = new File(path);


            fis = new FileInputStream(uploadFile);
            bis = new BufferedInputStream(fis);
            fos = response.getOutputStream();
            bos = new BufferedOutputStream(fos);



            response.reset();
            response.setHeader("Content-disposition", "attachment;filename =" + URLEncoder.encode(path, "utf-8"));


            int bytesRead = 0;
            byte[] buffer = new byte[4096];
            while((bytesRead = bis.read(buffer,0,4096)) != -1){
                bos.write(buffer, 0, bytesRead);
            }
            bos.flush();
            fis.close();
            bis.close();
            fos.close();
            bos.close();
            //return mapping.findForward("success");

            return null;
        } catch(Exception e){
            e.printStackTrace();
            System.out.println(path);
            ActionMessages downErrors = new ActionMessages();
            ActionMessage downError =  new ActionMessage("errors.download", path);
            downErrors.add(ActionMessages.GLOBAL_MESSAGE, downError);
            saveMessages(request, downErrors);
            return mapping.findForward("error");
        }

    }

[/code]
[b]问题补充:[/b]

对应第二种方法的
也是从论坛看来的

[code="java"]

public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)  {
        FileDownLoadForm fdform =(FileDownLoadForm)form;
        String path = fdform.getFilePath();


        response.setContentType("application/x-download");
        String filenamedownload = path;
        String filenamedisplay = path.substring(path.lastIndexOf("/")+1);


        try {
            filenamedisplay = URLEncoder.encode(filenamedisplay,"UTF-8");
            response.addHeader("Content-Disposition","attachment;filename=" + filenamedisplay);
            RequestDispatcher dispatcher = request.getRequestDispatcher(filenamedownload);
            if(dispatcher != null)
            {
                dispatcher.forward(request,response);
            }
            response.flushBuffer();

           return null ;
           //  return mapping.findForward("success");
        }
        catch(Exception e) {
            e.printStackTrace();
            ActionMessages downErrors = new ActionMessages();
            ActionMessage downError =  new ActionMessage("errors.download", path);
            downErrors.add(ActionMessages.GLOBAL_MESSAGE, downError);
            saveMessages(request, downErrors);
            return mapping.findForward("error");

        }

    }

[/code]

可以分两步,第一步处理下载之前的事务,第二步利用弹出窗口做下载。在弹出窗口上面做文章控制父页面的消息显示。
想直接一个请求做是不行的,因为response已经返回了的缘故。

如果跳转最后的页面不复杂,你可以直接在action里输出吧。。。上传文件直接用jsp就可以了,不用那么复杂

检查一下你的文件下载请求响应的顺序吧,action不会有什么问题的.

由于线性提交时间长
会看像假死一样.......

一般用ajax来作....成功页面
叫作异步....

建议用AJAX来检测用户下载,这样的界面比较友好,而且,最后只需要返回一个字符串或XML就可以了,很方便,而且,很友好