freemarker 宏嵌套nested 的使用

转载来源:http://blog.sina.com.cn/s/blog_7e5699790100z59g.html

模板页:

<#assign basePath = request.contextPath />
<#macro htmlHead title charset="utf-8" lang="zh-CN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=${charset}" />
  <meta http-equiv="Content-Language" content="${lang}"/>
  <title>${title}</title>
  <#nested>
</head>
</#macro>

<#macro htmlBody>
<body>
  <#nested>
</body>
</html>
</#macro>

 

--------------------------------------------------------------------------------------------------
调用模板的页:

<#include "/ftl/layout/layout1.ftl"/>
<@htmlHead title="FreeMarker宏测试 ">
  <script src="${basePath}/js/jquery1.2.6.pack.js" type="text/javascript"></script>
  <script type="text/javascript">
    function test(){
      var va = $("#test1").val();
      alert(va);
    } 
  </script>
</@htmlHead>

<@htmlBody>
  哈哈哈<br>
  <input id="test1" type="text" name="name1" value="我的祖国"><br>
  <a href="#" onclick="test()">测试jquery</a>
</@htmlBody>

 

posted @ 2017-03-30 14:54  小小小飞鱼  阅读(6972)  评论(0编辑  收藏  举报