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. Trusted Execution Technology (TXT) --- 启动控制策略(LCP)篇

    版权声明:本文为博主原创文章,未经博主允许不得转载.http://www.cnblogs.com/tsec/p/8428631.html 在TXT平台中,启动控制策略(Launch Control P ...

  2. IntelliJ IDEA(七) :Project Structure

    Project Structure “ 项目结构”对话框允许您管理项目和IDE级别的元素,例如Modules,Facets,Libraries, Artifacts和SDK. 在大多数情况下,左边部分 ...

  3. eclipse open call hierarchy无效

    问题: Eclipse中选中一个方法,右击选中open call hierarchy,不显示哪些地方调用了这个方法,却显示了这个方法里面调用了那些方法.前阵子还是好的,现在不知道为什么了. 解决: s ...

  4. http目录显示时间与服务器相差8小时

    一直用nginx做http服务,代码里访问过文件地址,并未认真关注过访问http目录下的时间戳.今天浏览文件的时候发现一个问题.web上显示的文件时间戳与服务器时间相比差8个小时.具体表现看下图: w ...

  5. 基本c功能使用不当导致崩溃

    一些基本的c语言操作,使用不当也会有出其不意的问题.比如我最近的一个项目中,用到几句代码: uint8_t * out_pcm = NULL; ....... if (NULL == out_pcm) ...

  6. [dsu on tree]【学习笔记】

    十几天前看到zyf2000发过关于这个的题目的Blog, 今天终于去学习了一下 Codeforces原文链接 dsu on tree 简介 我也不清楚dsu是什么的英文缩写... 就像是树上的启发式合 ...

  7. nginx + tomcat实现负载均衡

    作者Mr.Chen,转载请注明博客出处:http://www.cnblogs.com/cjh-notes/ 负载均衡 负载均衡就是流量分发,优选软件解决方案,成本低效果好. 实现步骤 第一步:下载安装 ...

  8. linux下qt的安装

    2.1环境的搭建 linux-> 2.1.1 ./qt-opensource-linux-x86-5.5.0.run 2.1.2 vim /etc/profile (.bashrc) expor ...

  9. LeetCode - 596. Classes More Than 5 Students

    There is a table courses with columns: student and class Please list out all classes which have more ...

  10. 打通MySQL的操作权限

    打通MySQL的操作权限 前面已经总结了<XAMPP的配置与使用>,虽然可以直接通过GUI控制面板去启动MySQL服务,但是有些相关的操作则需要在Windows中的CMD命令窗口中去对My ...