FreeMarker,WebWork 问题
我有一个使用 freemarker、webwork 和 java 编写的 Web 应用程序。现在,当用户单击“getReport”时,java 代码返回字符串变量(名为“otchet”),其中包含纯文本的整个报告,并显示以下页面:
simple.ftl:
<#if (otchet?exists)>
${otchet}
<#else>
<@ww.text name="report.none"/>
</#if>
工作正常。但是,我想以文本/纯文件下载的形式向用户提供此报告(包含在变量“otchet”中)。
我该如何解决这个问题?
I have a web application written using freemarker, webwork and java. Now when user clicks on "getReport", java code returns the string variable (named "otchet") which contains the whole report in plain text and the following page is displayed:
simple.ftl:
<#if (otchet?exists)>
${otchet}
<#else>
<@ww.text name="report.none"/>
</#if>
It is working OK. However, I would like instead to offer user this report (contained in the variable "otchet") as a text/plain file download.
How can I solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这正是 StreamResult 结果类型的用途。
示例:
在您的 WebWork XML 中:
在您的操作中:
This is exactly what the StreamResult result type is for.
Example:
In your WebWork XML:
In your action: