如何在 GWT 或 GXT 中使用单个按钮发送同步发布请求?
如何使用单个按钮发送 POST 请求而不创建任何附加的 FormPanel?
我想通过 POST 发送整个 HashMap 数据以填充报告,然后将此报告作为 XLS 文件流返回,因此用户应该看到“另存为...”对话框。
我无法通过 RequestBuilder 执行此操作,因为它会创建 AJAX 请求,并且无法以这种方式下载文件。
也许 Sencha 的 GXT 有解决方案?它也可以适合这里。
How can I send POST request with single button and without creating any FormPanel attached to it?
I want to send whole HashMap of data via POST for filling report and then return this report as XLS file stream, so the user should get "Save as..." dialog.
I can't do it by RequestBuilder as it creates AJAX requests and file can't be downloaded this way.
Maybe Sencha's GXT has a solution for this? It can fit here as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是我所做的。发送 AJAX POST。然后,您的服务器应发送 XLS 的 URL 作为响应。当客户端(浏览器/GWT)收到响应时,它会打开一个带有 XLS url 的隐藏 IFRAME。如果服务器将“Content-Disposition”标头设置为“Attachment”,则会出现“另存为”对话框。
Here's what I've done. Send an AJAX POST. Your server should then send the URL of the XLS as a response. When the client (browser/GWT) receives the response, it opens up a hidden IFRAME with the XLS url. If the server sets the 'Content-Disposition' header to 'Attachment', the 'Save As' dialog will appear.
您可以创建
new FormPanel("_self")
。此表单将直接返回您的 XLS 流,而不是返回到后台 iFrame。You can create
new FormPanel("_self")
. This form will return your XLS stream directly, not to the background iFrame.