如何在Spring MVC中生成多个页面的存档?
我想允许我的用户“批量导出”所选资源的存档,即 http://.../ resources/1、resource/2、resource/4、...,
我的想法是“将每个页面的 HTML 渲染为字符串并使用 java.util.zip 创建多文件存档。”
然后我的问题变成了“如何获取页面的 HTML 以便我可以循环它们?”
我无法找到一种方法来让 JstlView 呈现为字符串,也无法找到一种将 ServletOutputStream 设置为 ZipOutputStream 的方法。
我最后的想法是通过 HTTP 实际获取每个资源的 HTML。我想这很容易编码,但看起来相当复杂。有更好的办法吗? (也许与 RequestDispatcher.forward() 有关?)
I want to allow my users to "bulk export" an archive of selected resources, i.e., http://.../resource/1, resource/2, resource/4, ... ,
My thought was "render the HTML of each page to a string and use java.util.zip to create a multifile archive."
My problem then became "how to get the HTML of a page so that I can loop over them?"
I cannot figure out a way to get a JstlView to render to a String, nor can I see a way to set the ServletOutputStream to be a ZipOutputStream.
My last thought is to actually GET the HTML of each of the resources via HTTP. I imagine that will be easy enough to code, but it seems pretty byzantine. Is there a better way? (Perhaps something with RequestDispatcher.forward()? )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 SwallowingHttpServletResponse 来自 DWR(或 PageResponseWrapper 来自 Sitemesh)作为参数RequestDispatcher.include() 然后从该响应对象获取输出。
请参阅我对 这个问题。
Use a SwallowingHttpServletResponse from DWR (or a PageResponseWrapper from Sitemesh) as a parameter to RequestDispatcher.include() and then get the output from that response object.
See my response (no pun intended) to this question.