【问题标题】:Export Functionality in Tapestry 4Tapestry 4 中的导出功能
【发布时间】:2015-04-24 10:51:56
【问题描述】:

我需要开发一个点击按钮的导出功能,以便我可以将查看的 HTML 页面导出到 word 文档中。

我已经在 J​​SP/Java 中实现了相同的功能(下面是代码),但是 无法在 Tapestry 中开发相同的功能。

能否请您帮助我,以便我可以开发相同的功能 挂毯 4.

<body>  
<%  
    String exportToWord;  
    exportToWord = request.getParameter("exportToWord");  
    if (exportToWord != null &&  exportToWord.toString().equalsIgnoreCase("YES")){
    response.setContentType("application/vnd.ms-word"); 
    response.setHeader("Content-Disposition", "inline;
    filename="+"word.doc");}
%>  
This is the plain text.<p><i>This is the italic text. </i>  
<p><b>This is the old text. </b>    
<p><s>This is the strike text.</s>
<p><font color="green">This is he color text. </font> 
<p><a href="#">This is hyperlink. </a>
<p><%if exportToWord == null) {%><a href="word.jsp?exportToWord=YES">Export to word</a> 
<%}%>
</body>
</html>  

【问题讨论】:

  • 如果您使用的是 Tapestry 5,那么您可以点击以下链接,因为在我们的项目中我们使用的是旧版本。 stackoverflow.com/questions/29520097/…
  • yeehaaah 牛仔!!!那是你那里的一些非常 hacky JSP!!!

标签: tapestry


【解决方案1】:

您确定要发送 html 并假装它是 word 文档吗?你最好使用Apache POI 之类的东西来生成正确的文档。

执行此操作的“挂毯方式”是通过从组件操作(或从页面的 onActivate() 事件)返回 StreamResponse。一些文档here。有关下载动态生成的 pdf 的示例,请参阅 here。

如果您真的想将页面 html 作为文档发送,您可以使用 tapestry-stitch capture 或 tapestry-offline 将页面/组件呈现为字符串。我认为这真的很hacky。

【讨论】:

  • 这些文档属于 Tapestry 5,我正在开发 Tapestry 4。对于 Tapestry 5,我已经找到了解决问题的方法(请查看链接 stackoverflow.com/questions/29520097/…),非常感谢如果您可以在 Tapestry 4 中提出一些解决方案。
猜你喜欢
  • 1970-01-01
  • 2011-11-10
  • 1970-01-01
  • 1970-01-01
  • 2021-06-18
  • 2017-07-01
  • 2011-12-10
  • 1970-01-01
  • 2020-05-30
相关资源
最近更新 更多