我正在开发一个使用 struts2 构建的网站。我们的绝大多数目标都会生成 xml,因此将结果映射到 jsp 页面是有意义的。我们的几个目标实际上生成了二进制文件。我想知道是否有一种方便的方法来表示结果应该来自 servlet/控制器而不是 jsp。
显然,这可以通过修改 web.xml 来完成,这样 struts 过滤器不适用于这些目标并将这些目标映射为 servlet,但这并不理想。目前,struts 过滤器适用于整个站点,我们希望保持这种状态。
有想法吗?
谢谢!
I'm working on on a site built using struts2. The vast majority of our targets generate xml, so mapping the result to a jsp page makes sense. A couple of our targets actually generated binaries. I'm wondering if there is a convenient way to say that the result should come from a servlet/controller instead of a jsp.
Obviously this could be done by modifying the web.xml so the struts filter doesn't apply to those targets and mapping those targets as servlets, but this is non-ideal. Currently, the struts filter applies to the entire site, and we would like to keep it that way.
Ideas?
Thanks!
发布评论
评论(2)
我不确定我是否理解您的场景,但在我看来您想要 流结果
I am not sure I understand you scenario, but it seems to me you want the Stream Result
在这里您可以找到一个优秀的教程,其中包含有关 Struts2 文件上传和文件下载的代码示例,其中涵盖了流结果:
http://www.jeetrainers.com/struts2-course/chapter12-13-1-1#slide
Here you can find an excellent tutorial with code examples about Struts2 file upload and file download that covers the Stream Result:
http://www.jeetrainers.com/struts2-course/chapter12-13-1-1#slide