11.12 模板引擎视图页面
我们使用Freemarker模板引擎。我们在templates目录下新建一个list.ftl文件,内容如下:
1. <html>
2. <head>
3. <title>Blog!!!</title>
4. </head>
5. <body>
6. <table>
7. <thead>
8. <th>序号</th>
9. <th>标题</th>
10. <th>作者</th>
11. <th>发表时间</th>
12. <th>操作</th>
13. </thead>
14. <tbody>
15. <#-- 使用FTL指令 -->
16. <#list articles as article>
17. <tr>
18. <td>${article.id}</td>
19. <td>${article.title}</td>
20. <td>${article.author}</td>
21. <td>${article.gmtModified}</td>
22. <td><a href="#" target="_blank">编辑</a></td>
23. </tr>
24. </#list>
25. </tbody>
26. </table>
27. </body>
28. </html>
其中,<#list articles as article>是Freemarker的循环指令,${}是 Freemarker引用变量的方式。
提示:关于Freemarker的详细语法可参考 <http://freemarker.org/> 。
