如何在RemoteServiceServlet中生成文件并将其发送给用户?

编程入门 行业动态 更新时间:2024-10-28 16:26:13
本文介绍了如何在RemoteServiceServlet中生成文件并将其发送给用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 也许我可以禁用RemoteServiceServlet响应序列化或使用返回ServletOutputStram的方法定义RemoteService接口?我希望不要在任何数据库中保存请求,以便在另一个请求中处理它。 解决方案

如果您想提供下载到用户,你可以这样做:

  • 编写另一个servlet,通过ServletResponse写出文件内容
  • 确保你有一个二进制头文件,并在那里提供文件名。
  • 在你的客户端中,制作一个< iframe ..> (这个widget类是 Frame ),并将它的url指向新的servlet。
  • 由于二进制标题,您的浏览器现在将向用户提供另存为弹出窗口。这应该是全部。

    Maybe I can disable RemoteServiceServlet response serialization or define RemoteService interface with method that returns ServletOutputStram? I would like not to save request in any database to file to process it in another request.

    解决方案

    If you want to provide a download to the user, you can do it like this:

  • Write another servlet which simply writes out the file content through the ServletResponse
  • Make sure you have a binary header and provide the filename in there, too.
  • In your client, make an <iframe ..> (The widget class for this is Frame) and point its url to your new servlet.
  • Due to the binary header your browser will now provide the user with a Save as.. popup. That should be all.

    更多推荐

    如何在RemoteServiceServlet中生成文件并将其发送给用户?

    本文发布于:2023-07-13 22:18:50,感谢您对本站的认可!
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:发送给   文件   用户   如何在   并将其

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!