SiteMesh如何結合Freemarker及velocity使用
Freemarker 入門示例 http://www.dhdzp.com/article/197670.htm
FreeMarker 整合Struts2示例 http://www.dhdzp.com/article/197698.htm
SiteMesh入門示例 http://www.dhdzp.com/article/197668.htm
那么如何將Freemarker與SiteMesh結合起來使用,這在官方示例中已經(jīng)有了相關例子。
查看官方示例中decorators.xml文件,里面有一段是關于Freemarker使用的
<decorator name="freemarker" page="freemarker.ftl"> <pattern>/freemarker.html</pattern> </decorator>
也就是說請求freemarker.html時會攔截并處理,并發(fā)freemarker.ftl作為默認頁面處理
看一下freemarker.ftl的內(nèi)容,因為在JSP中是使用標簽來獲取Head或者Body的,所以在這個頁面主要是看看如何獲取這些元素。
<html>
<head>
<title>Freemarker Decorator - ${title}</title>
<link href="${base}/decorators/main.css" rel="external nofollow" rel="stylesheet" type="text/css">
${head}
</head>
<body>
<div id="pageTitle">${title}</div>
<hr/>
${body}
<div id="footer">
<b>Disclaimer:</b> This site is an example site to demonstrate SiteMesh. It serves no other purpose.
</div>
</body>
</html>
可以看到,直接通過$來獲取幾個元素,${title}、 ${head}、${base}、${title}、${body}
velocity的結合是一樣的,看看關于他的配置
<decorator name="velocity" page="velocity.vm"> <pattern>/velocity.html</pattern> </decorator>
看看velocity.vm頁面內(nèi)容
<html>
<head>
<title>Velocity Decorator - $title</title>
<link href="$base/decorators/main.css" rel="external nofollow" rel="stylesheet" type="text/css">
$head
</head>
<body>
<div id="pageTitle">$title</div>
<hr/>
$body
<div id="footer">
<b>Disclaimer:</b> This site is an example site to demonstrate SiteMesh. It serves no other purpose.
</div>
</body>
</html>
不多解釋了。
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
- 詳解使用Mybatis-plus + velocity模板生成自定義的代碼
- c#基于NVelocity實現(xiàn)代碼生成
- Vue中JS動畫與Velocity.js的結合使用
- 如何解決SpringBoot2.x版本對Velocity模板不支持的方案
- SpringBoot與velocity的結合的示例代碼
- 聊聊JS動畫庫 Velocity.js的使用
- springMVC+velocity實現(xiàn)仿Datatables局部刷新分頁方法
- 詳解velocity模板使javaWeb的html+js實現(xiàn)模塊化
- Mybatis velocity腳本的使用教程詳解(推薦)
- JAVA velocity模板引擎使用實例
- html文件中jquery與velocity變量中的$沖突的解決方法
- Java 如何使用Velocity引擎生成代碼
相關文章
Alibaba?Nacos配置中心動態(tài)感知原理示例解析
這篇文章主要介紹了Alibaba?Nacos配置中心動態(tài)感知原理示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-08-08
關于SpringBoot中controller參數(shù)校驗的使用
本文主要介紹了關于SpringBoot中controller參數(shù)校驗的使用,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2023-01-01

