SiteMesh如何結(jié)合Freemarker及velocity使用
Freemarker 入門示例 http://chabaoo.cn/article/197670.htm
FreeMarker 整合Struts2示例 http://chabaoo.cn/article/197698.htm
SiteMesh入門示例 http://chabaoo.cn/article/197668.htm
那么如何將Freemarker與SiteMesh結(jié)合起來使用,這在官方示例中已經(jīng)有了相關(guān)例子。
查看官方示例中decorators.xml文件,里面有一段是關(guān)于Freemarker使用的
<decorator name="freemarker" page="freemarker.ftl"> <pattern>/freemarker.html</pattern> </decorator>
也就是說請求freemarker.html時會攔截并處理,并發(fā)freemarker.ftl作為默認(rèn)頁面處理
看一下freemarker.ftl的內(nèi)容,因為在JSP中是使用標(biāo)簽來獲取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的結(jié)合是一樣的,看看關(guān)于他的配置
<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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 詳解使用Mybatis-plus + velocity模板生成自定義的代碼
- c#基于NVelocity實現(xiàn)代碼生成
- Vue中JS動畫與Velocity.js的結(jié)合使用
- 如何解決SpringBoot2.x版本對Velocity模板不支持的方案
- SpringBoot與velocity的結(jié)合的示例代碼
- 聊聊JS動畫庫 Velocity.js的使用
- springMVC+velocity實現(xiàn)仿Datatables局部刷新分頁方法
- 詳解velocity模板使javaWeb的html+js實現(xiàn)模塊化
- Mybatis velocity腳本的使用教程詳解(推薦)
- JAVA velocity模板引擎使用實例
- html文件中jquery與velocity變量中的$沖突的解決方法
- Java 如何使用Velocity引擎生成代碼
相關(guān)文章
java查詢近七日數(shù)據(jù)功能的實現(xiàn)
這篇文章主要介紹了java查詢近七日數(shù)據(jù)功能的實現(xiàn),文章內(nèi)容詳細(xì),簡單易懂,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2023-01-01java如何用Processing生成馬賽克風(fēng)格的圖像
這篇文章主要介紹了如何用java如何用Processing生成馬賽克風(fēng)格的圖像,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-03-03mall整合SpringTask實現(xiàn)定時任務(wù)的方法示例
這篇文章主要介紹了mall整合SpringTask實現(xiàn)定時任務(wù)的方法示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-06-06詳解MyBatis中Executor執(zhí)行SQL語句的過程
MyBatis中獲取SqlSession時會創(chuàng)建執(zhí)行器Executor并存放在SqlSession中,本篇文章將以MapperMethod的execute() 方法作為起點,對MyBatis中的一次實際執(zhí)行請求進(jìn)行說明,并結(jié)合源碼對執(zhí)行器Executor的原理進(jìn)行闡釋2023-07-07解決新版 Idea 中 SpringBoot 熱部署不生效的問題
這篇文章主要介紹了解決新版 Idea 中 SpringBoot 熱部署不生效的問題,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-08-08