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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM