0

我使用 fileReference.download() 下载文件。fileReference 向 java servlet 发送请求。在 servlet 中,可能会检查一些错误。例如错误 - “找不到文件”。我想将错误发送到 flex 端。我尝试了很多方法,但是 flex 中的 fileReference 无法接收它们。如

response.sendError(HttpServletResponse.SC_NOT_FOUND, "File not found");

或者

PrintWriter out = resp.getWriter(); out.print("File not found");

似乎 fileReference 无法触发事件“DataEvent.UPLOAD_COMPLETE_DATA”和“HTTPStatusEvent.HTTP_STATUS”。有人可以告诉我如何在 fileReference 中获取 servlet 错误消息。谢谢

4

2 回答 2

0

我不相信 FileReference.download 调度 HttpStatus 事件,也不公开状态代码。

您只能监听 IOErrorEvent。

于 2011-07-20T04:08:48.697 回答
0

认为没有解决办法。我尝试了几种方法,例如使用 500 响应、使用消息响应 sendError、返回 XML 文档(但您无法控制下载的内容)。我通过创建适合大多数情况的“全方位错误消息”解决了这个问题(您没有权限或内容不可用......)

其他解决方案是使用 navigateTo 下载,但您需要打开浏览器窗口。

于 2012-06-03T15:08:07.073 回答