在 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 上传文件 这个功能就不好用了。
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/jsp/errorAlert.jsp</location>
</error-page>
出现异常时都会转到errorAlert.jsp页面上 ,使用 ServletFileUpload 接受 swfupload 上传文件 这个功能就不好用了。
有提供错误的回调函数吧。
如果是异常你在程序中返回相应的错误码,客户端根据错误码来提示不行吗?
你应该把exception throw,并在action中throw,JSP错误处理页面才会起作用
是吗?真的是这样吗?在官方的实例中有一个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"