GWT: How to return (and handle) an error from multipart form (file) upload
我有一个Google Web Toolkit(多部分)表单,该表单将文件发布到我的servlet中。当servlet中发生错误情况时,我返回一个错误。一切正常后,我返回一个JSON字符串。
1 2 3 4 5 6 7 8 9 10 | ... response.setContentType("text/html"); response.setCharacterEncoding("UTF8"); response.getWriter().write(out.toString()); } catch (FileUploadException e) { response.sendError(500, e.getMessage()); } catch (Exception e) { response.sendError(500, e.getMessage()); } |
问题是我找不到在客户端处理此问题的方法。这是在发布正常且返回错误代码时触发的事件。但是我找不到方法,确定可以还是不可以?以及如何从客户端代码的Exception中获取错误消息?
1 2 3 4 | @UiHandler("form") void submitComplete(SubmitCompleteEvent event) { ... |
当前,似乎没有合适的方法可用(例如
GWT的Google网上论坛的相关线程:一个和两个。