1、Beetl簡介javascript
1. 什麼是Beetlhtml
Beetl目前版本是2.9.3,相對於其餘java模板引擎,具備功能齊全,語法直觀,性能超高,以及編寫的模板容易維護等特色。使得開發和維護模板有很好的體驗。是新一代的模板引擎。總得來講,它的特性以下:java
2.文檔(http://ibeetl.com/guide/)web
2、ArticleController返回帶有beetl標籤的html視圖用來解析「articles」屬性ajax
/** * 首頁內容(獲取top15文章) * @param * @return *//* @GetMapping(value = "/index") public String index(Model model) throws Exception { List<JsCmsArticlesEntity> articles = this.frontDeskService.getTop15Articles(); model.addAttribute("articles", articles); return "templates/index"; }
3、index.html架構
一、<% layout('default.html'){ }%>是頁面公共部分,能夠實現多個html公用app
二、<% for(article in articles){ %> 經過for循環遍歷aticles集合,而後用「.」操做${article.createAt}取值框架
<% layout('default.html'){ %> <div class="main"> <div class="article__wrap" id="article__"> <% //ajax片斷開始 #ajax nextTable: { %> <% for(article in articles){ %> <article id="article" class="article__item fn-flex"> <!--<div class="article__meta article__meta--0"> <div> ${article.createAt} </div> <div> <a href="electron-bnd2-b3id=H9oxzSym.html"> ${article.viewCount}瀏覽 </a> </div> <div> <a href="electron-bnd2-b3id=H9oxzSym.html#pipeComments"> ${article.commentCount}評論 </a> </div> </div>--> <div class="fn-flex-1 article__main"> <h2 class="article__title"> <a rel="bookmark" href="/articles/${article.id!}"> ${article.title} </a> </h2> <section data-link="electron-bnd2-b3id=H9oxzSym.html" class="pipe-content__reset fn-flex-1" data-author="Vanessa"> ${article.content} </section> <div> <a class="tag" rel="tag" href="tags/bnd2-b3id=H9oxzSym.html">${article.tags}</a> </div> </div> </article> <% } %> <% //ajax片斷結尾 } %> </div> <div class="ft-center"> <nav class="pagination"> <a class="pagination__item" id="loadMore" href="javascript:void(0);"> 加載更多 </a> </nav> </div> </div> <% } %>