在freemarker中使用zk标签

    主要是为了使用zk spreasheets的标签,简述下步骤

    首先是jsp里的写法

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.zkoss.org/jsp/zul" prefix="z" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ZK Spreadsheet</title>
</head>
<body>
<z:page zscriptLanguage="java"><%-- this is Jsp valid Comment, do not use XML comment. --%>
	<h2>ZK Spreadsheet</h2>
	<z:window height="100%">
		<z:spreadsheet id="fluSpreadsheet" src="/xls/海水质量监测-水质数据.xls" width="100%" height="100%" 
		maxrows="51" maxcolumns="4" style="border:1px solid black;"/>
	</z:window>
</z:page>
</body>
</html>
 

引入到freemaker中

先在web.xml中加入

<servlet>
		<servlet-name>JspSupportServlet</servlet-name>
		<servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
 

  配置一个struts路由请求

<package name="index" extends="struts-default">

		<action name="freemarker" class="app.action.IndexAction">
			<result name="success" type="freemarker">/WEB-INF/freemarker_test.ftl
			</result>
		</action>

	</package>

 freemaker页面如下

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<#assign z=JspTaglibs["http://www.zkoss.org/jsp/zul"] /> 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ZK Spreadsheet</title>
</head>
<body>
<@z.page zscriptLanguage="java">
	<h2>ZK Spreadsheet</h2>
	<#list test as test>
	<h4>${test}</h4>
	</#list>
	<@z.window height="100%">
		<@z.spreadsheet id="fluSpreadsheet" src="/xls/海水质量监测-水质数据.xls" width="100%" height="100%" 
		maxrows="51" maxcolumns="42" style="border:1px solid black;"/>
	</@z.window>
</@z.page>
</body>
</html>

 <#assign z=JspTaglibs["http://www.zkoss.org/jsp/zul"] /> 声明了zk的标签,以z作为前缀调用,ok,大功告成。

相关推荐