在 struts1  action 中 使用 ServletFileUpload 接受 swfupload 上传的文件,并将文件存入数据库,当存入数据库过程中出现异常,客户端如何得到错误提示 ?正常情况 在 web.xml 中 配置 
  <error-page>
    <exception-type>java.lang.Exception</exception-type>
     <location>/jsp/errorAlert.jsp</location>
  </error-page>
出现异常时都会转到errorAlert.jsp页面上 ,使用 ServletFileUpload 接受 swfupload 上传文件 这个功能就不好用了。

解决方案 »

  1.   

    swfupload
    有提供错误的回调函数吧。
    如果是异常你在程序中返回相应的错误码,客户端根据错误码来提示不行吗?
      

  2.   

    现在是  ServletFileUpload 接收了(放入缓存或临时目录) swfupload就认为成功了 ,下一步存数据库无法监控
      

  3.   

    应该是没有把发生的异常throw,而是在catch后直接处理了(例如直接printStackTrace()了)。
    你应该把exception throw,并在action中throw,JSP错误处理页面才会起作用
      

  4.   

    我没用 try catch 直接抛出   
      

  5.   


    是吗?真的是这样吗?在官方的实例中有一个PHP是专门来处理上传吧。window.onload = function() { var settings = { flash_url : "../swfupload/swfupload.swf", upload_url: "upload.php", post_params: {"PHPSESSID" : ""}, file_size_limit : "100 MB", file_types : "*.*", file_types_description : "All Files", file_upload_limit : 100, file_queue_limit : 0, custom_settings : { progressTarget : "fsUploadProgress", cancelButtonId : "btnCancel" }, debug: false, // Button settings button_image_url: "images/TestImageNoText_65x29.png", button_width: "65", button_height: "29", button_placeholder_id: "spanButtonPlaceHolder", button_text: '<span class="theFont">Hello</span>', button_text_style: ".theFont { font-size: 16; }", button_text_left_padding: 12, button_text_top_padding: 3, // The event handler functions are defined in handlers.js file_queued_handler : fileQueued, file_queue_error_handler : fileQueueError, file_dialog_complete_handler : fileDialogComplete, upload_start_handler : uploadStart, upload_progress_handler : uploadProgress, upload_error_handler : uploadError, upload_success_handler : uploadSuccess, upload_complete_handler : uploadComplete, queue_complete_handler : queueComplete // Queue plugin event }; swfu = new SWFUpload(settings);upload_url: "upload.php"
      

  6.   

    解决了 在errorAlert.jsp加入 <% response.setStatus(-200); %>就搞定了