我需要开发一个点击按钮的导出功能,以便我可以导出查看的HTML页面到word文档。
我已经在JSP/Java (下面是代码)中实现了相同的功能,但无法在Tapestry中开发相同的功能。
您能帮我在Tapestry4中开发同样的功能吗?
<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> 发布于 2015-04-29 20:10:06
您确定要发送html并假装它是word文档吗?你最好使用像Apache POI这样的东西来生成合适的文档。
实现这一点的“tapestry方式”是从组件操作(或页面的onActivate()事件)返回一个StreamResponse。一些文档here。有关下载动态生成的pdf的示例,请参阅here。
如果您确实希望将页面html作为文档发送,则可以使用诸如tapestry-stitch capture或tapestry-offline之类的内容将页面/组件呈现为字符串。我认为这真的很老套。
https://stackoverflow.com/questions/29845593
复制相似问题