1、设置数据源

 /**
      *
      * @Title:student
      * @Description:
      * @param:@param name
      * @return: void
      * @throws
      */
     private void student(String name)
     {
         ft.printFtl(name,root);
     }

     /**
      *
      * @Title:studentFile
      * @Description:
      * @param:@param name
      * @param:@param fileName
      * @return: void
      * @throws
      */
     private void studentFile(String name,String fileName)
     {
         ft.printFile(name, root, fileName);
     }

     /**
      * 测试freemarker中的list
      * @Title:testList
      * @Description:
      * @param:
      * @return: void
      * @throws
      */
     @Test
     public void testList()
     {
         List<Student> students = Arrays.asList(new Student("张三丰","男",26,new Date(1988-12-12),"湖北省武汉市武昌洪山区",78451214),
                                               new Student("李雪","女",20,new Date(1991-12-18),"湖北省武汉市武昌",85451214),
                                               new Student("刘刘","男",22,new Date(1989-10-18),"湖南省长沙市",96551214),
                                               new Student("吴明","女",21,new Date(1990-12-18),"广东省深圳市",56132012));
         root.put("students", students);
         ft.printFtl("stu.ftl",root);
     }

2、新建stu.ftl

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
   <head>
     <title>学生信息</title>

     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
     <meta http-equiv="description" content="this is my page">
     <meta http-equiv="content-type" content="text/html; charset=UTF-8">

   </head>

   <body>
           <#list students as student>
                     姓名:${student.studentName}
              性别:${student.studentSex}
              年龄:${student.studentAge}
              生日:${(student.studentBirthday)?string("yyyy-MM-dd")}
             地址:${student.studentAddr}
               QQ:${student.studentQQ}<br/>
           </#list>
   </body>
 </html>

freemarker之list遍历(八)的更多相关文章

  1. Freemarker中如何遍历List

     Freemarker中如何遍历List(附源码) 关键词(Keyword):Freemarker,Freemarker遍历list 在Freemarker应用中经常会遍历List获取需要的数据, ...

  2. freemarker list (长度,遍历,下标,嵌套,排序)

    1. freemarker获取list的size : Java ArrayList<String> list = new ArrayList<String>(); Freema ...

  3. 关于在freemarker模板中遍历数据模型List<JavaBean>的经验

    本文采用简单的servlet作为后台处理数据的工具,前台使用freemarker的ftl模板作为输出工具,简单说明怎样将封装有实体类对象的List集合注入到ftl模板中并且成功的在遍历显示出来,之前在 ...

  4. freemarker 前端 判读 遍历 取值

    <#if content?length gt 100> ${content[0..100]}... <#else> ${content} </#if> freema ...

  5. Freemarker中遍历List以及内置函数使用

    在Freemarker应用中经常会遍历List获取需要的数据,并对需要的数据进行排序加工后呈现给用户. 那么在Freemarker中如何遍历List,并对List中数据进行适当的排序呢?一. Free ...

  6. FreeMarker 集合遍历

    freemarker list (长度,遍历,下标,嵌套,排序) 1. freemarker获取list的size : Java ArrayList<String> list = new ...

  7. FreeMarker惯用内置函数

    1.sequence?first 返回sequence的第一个值. 2.sequence?last 返回sequence的最后一个值. 3.sequence?reverse 将sequence的现有顺 ...

  8. Freemarker 内置函数 数字、字符串、日期格式化用法介绍

    在用FreeMarker过程中,感觉FreeMarker的字符串,日期,集合等处理能力还是很强大的,上网搜了一些资料,整理如下,以便能帮助大家更熟练的应用Freemarker完成项目开发. 一.Seq ...

  9. [转]freemarker中的list

    转至:http://zhuyuehua.iteye.com/blog/1975251 freemarker list (长度,遍历,下标,嵌套,排序) 1. freemarker获取list的size ...

随机推荐

  1. BZOJ 3720: Gty的妹子树 [树上size分块]

    传送门 题意: 一棵树,询问子树中权值大于$k$的节点个数,修改点权值,插入新点:强制在线 一开始以为询问多少种不同的权值,那道CF的强制在线带修改版,直接吓哭 然后发现看错了这不一道树上分块水题.. ...

  2. 【模板小程序】求第n个质数

    #include <iostream> #include <vector> using namespace std; int nth_prime(int n) { vector ...

  3. 训练 smallcorgi/Faster-RCNN_TF 模型(附ImageNet model百度云下载地址)

    1. 下载训练.验证.测试数据和 VOCdevkit,下载地址: http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2 ...

  4. Vi/Vim的快捷方式

    1 vi/ vim键盘图 2 文字解说 进入编辑模式的6种方式: i在光标前插入 I在行首插入 a在光标后插入 A在行末插入 o在下一行插入 O在上一行插入 删除字符 x 删除当前字符 X 删除前一个 ...

  5. PHP的 first day of 和 last day of

    话不多说,先上代码(当前是2017年6月2日) echo date("Y-m-d", strtotime("2017-02 first day of")).'& ...

  6. python学习:Dmidecode系统信息(一)

    #!/usr/bin/env python   from subprocess import Popen, PIPE   p = Popen(['dmidecode'], stdout=PIPE) d ...

  7. css里面如何设置body背景图片满屏

    @{    Layout = null;    ViewBag.Title = "Login Page";} <!DOCTYPE html> <html>& ...

  8. CENTOS6.6下mysql5.6的源码安装

    本文来自我的github pages博客http://galengao.github.io/ 即www.gaohuirong.cn 1.下载:当前mysql版本到了5.6.28 http://dev. ...

  9. Oracle创建表时Storage参数具体含义

    本文通过图表和实例的阐述在Oracle数据库创建新表时Storage的参数具体含义. 可用于:表空间.回滚段.表.索引.分区.快照.快照日志 参数名称 缺省值 最小值 最大值 说明 INITIAL 5 ...

  10. java程序员理解js中的闭包

    1.闭包概念: 就是函数内部通过某种方式访问一个函数内部的局部变量 再次理解: 闭包产生原因: 1.内部函数引用了外部函数的变量 作用:延长局部变量的生命周期 让函数外部可以调用到函数内部的数据 利用 ...