freemarker之include指令

1、父页面ftl

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>学生信息</title>

  </head>

  <body>
     <#include "/inc/top.ftl"/>
    	姓名:${student.studentName}
     	性别:${student.studentSex}
     	年龄:${student.studentAge}
     	生日:${(student.studentBirthday)?string("yyyy-MM-dd")}
    	地址:${student.studentAddr}
  		QQ:${student.studentQQ}
  		<#if student.studentAge lt 12>
  		     ${student.studentName}不是一个初中生
  		<#elseif student.studentAge lt 15>
  		     ${student.studentName}不是一个高中生
  		<#elseif student.studentAge lt 18>
  		     ${student.studentName}不是一个大学生
  		<#else>
  		     ${student.studentName}是一个大学生
  		</#if>

  </body>
</html>

2、子页面ftl

 <h1>欢迎,进入学生管理系统!</h1>

3、测试方法

Map<String,Object> root = null;

	/**
	 *
	 * @Title:testStudent
	 * @Description:
	 * @param:
	 * @return: void
	 * @throws
	 */
	@Test
	public void testStudent()
	{
		//创建数据模型
		root = new HashMap<String,Object>();
		root.put("student", new Student("张三丰","男",16,new Date(1988-12-12),"湖北省武汉市武昌洪山区",78451214));
		student("student.ftl");
		studentFile("student.ftl","student1.html");
	}

	/**
	 *
	 * @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);
	}
	

4、生成HTML页面代码

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>学生信息</title>

  </head>

  <body>
      <h1>欢迎,进入学生管理系统!</h1>
    	姓名:张三丰
     	性别:男
     	年龄:16
     	生日:1970-01-01
    	地址:湖北省武汉市武昌洪山区
  		QQ:78,451,214
  		     张三丰不是一个大学生

  </body>
</html>

freemarker之include指令的更多相关文章

  1. freemarker之include指令(九)

    freemarker之include指令 1.父页面ftl <html> <head> <meta http-equiv="content-type" ...

  2. FreeMarker之FTL指令

    assign指令 此指令用于在页面上定义一个变量 (1)定义简单类型: <#assign linkman="周先生"> 联系人:${linkman} (2)定义对象类型 ...

  3. 浅谈JSP中include指令与include动作标识的区别

    JSP中主要包含三大指令,分别是page,include,taglib.本篇主要提及include指令. include指令使用格式:<%@ include file="文件的绝对路径 ...

  4. JSP(include指令与<jsp:include>动作的区别)

    <%@ page language= "java" contentType="text/html;charset=UTF-8" %><html ...

  5. jsp include指令

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"% ...

  6. include指令和include标签的区别

    区别 类别 语法 发生作用时间 包含的内容 转化成Servlet 编译时间 运行时间 include指令 <%@ include file="" %> 页面交换 实际内 ...

  7. 使用-MM生成include指令和依赖生成(make include directive and dependency generation with -MM)

    I want a build rule to be triggered by an include directive if the target of the include is out of d ...

  8. include动作标记和include指令标记学习笔记

    我的jsp学习参考书是耿祥义,张跃平编著的jsp大学使用教程这本书,我也向大家推荐这本书,我觉得这本书适合我的学习方式,知识的讲解透彻易懂. include指令标记                   ...

  9. Java学习-035-JavaWeb_004 -- JSP include 指令

    inclue 指令是将不同的文件插入到 JSP 网页中,这些文件可以是文本文件.HTML文件.JSP 文件,指令语法如下: <%@include file="相对路径"%&g ...

随机推荐

  1. for in 在数组和json中

    数组中也有for--in,相较于对象中的用法是有区别的:数组中 var arr = ['曹操','曹植','曹丕'] for(i in arr){ console.log(i) //0 1 2 con ...

  2. hiveql笔记(一)

    1.创建表 create table if not exists mydb.employees{ name String COMMENT 'Employee name', salary FLOAT C ...

  3. Bruce Eckel的资源

    1 GitHub的技术博客 2 On Java 8 – Bruce Eckel 3 artima_weblogs - Bruce Eckel 4 back issues 5 eckel-oo-prog ...

  4. 备忘录之 —— .bashrc(IC工具篇)

    好久没有使用这些IC工具了,装在自己的虚拟机中的Linux系统里面,现在想要卸载掉,想起之前自己辛辛苦苦的折腾这些工具配置,如果直接删除,感觉未免有点对不起自己的劳动成果,或许以后再也用不到了,就当是 ...

  5. mac攻略(2) -- apache站点配置

    [http://www.cnblogs.com/redirect/p/6112164.html] Mac OS X 中默认有两个目录可以直接运行你的 Web 程序, 一个是系统级的 Web 根目录:/ ...

  6. PPPoE拨号流程

    PPPoE(Point to Point Protocol over Ethernet,基于以太网的点对点协议)的工作流程包含发现(Discovery)和会话(Session)两个阶段,发现阶段是无状 ...

  7. 机器学习03:K近邻算法

    本文来自同步博客. P.S. 不知道怎么显示数学公式以及排版文章.所以如果觉得文章下面格式乱的话请自行跳转到上述链接.后续我将不再对数学公式进行截图,毕竟行内公式截图的话排版会很乱.看原博客地址会有更 ...

  8. python并发编程之多进程(一):进程开启方式&多进程

    一,进程的开启方式 利用模块开启进程 from multiprocessing import Process import time,random import os def piao(name): ...

  9. 关于 JS 拖拽功能的冲突问题及解决方法

    前言 我在之前写过关于 JS 拖拽的文章,实现方式和网上能搜到的方法大致相同,别无二致,但是在一次偶然的测试中发现,这种绑定事件的方式可能会和其它的拖拽事件产生冲突,由此产生了对于事件绑定的思考.本文 ...

  10. 每个前端开发者必会的 20 个 JavaScript 面试题

    JavaScript 未声明变量直接使用会抛出异常:var name is not defined,如果没有处理异常,代码就停止运行了.但是,使用typeof undeclared_variable并 ...