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. Cookie简述

    1. Cookie是什么? Cookie(Cookies,浏览器缓存), 是指某些网站为了辨别用户身份.进行session跟踪而储存在用户本地终端上的数据(通常经过加密). 2. Cookie的作用: ...

  2. LINUX文件定位

    body, table{font-family: 微软雅黑; font-size: 10pt} table{border-collapse: collapse; border: solid gray; ...

  3. ABP官方文档翻译 7.2 Hangfire集成

    Hangfire集成 介绍 ASP.NET Core集成 ASP.NET MVC 5.x集成 面板授权 介绍 Hangfire是一个综合的后台job管理器.你可以 把它集成到ABP,用来取代默认的后台 ...

  4. JS 特殊字符的验证的问题

    个人的JS 的收集方便下次的使用做百度查询: 1. 特殊字符的验证: var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].&l ...

  5. Linux压缩解压命令汇总

    01-.tar格式 解包:[*******]$ tar xvf FileName.tar 打包:[*******]$ tar cvf FileName.tar DirName (注:tar是打包,不是 ...

  6. HashMap----工作原理

    先来些简单的问题 "你用过HashMap吗?" "什么是HashMap?你为什么用到它?" 几乎每个人都会回答"是的",然后回答HashMa ...

  7. markdown的流程图、时序图、甘特图画法

    https://www.jianshu.com/p/a9ff5a9cdb25 Markdown里面的序列图 https://shd101wyy.github.io/markdown-preview-e ...

  8. Nginx的try_files指令和命名location使用实例

    Nginx的配置语法灵活,可控制度非常高.在0.7以后的版本中加入了一个try_files指令,配合命名location,可以部分替代原本常用的rewrite配置方式,提高解析效率. 下面是一个使用实 ...

  9. 在OS X系统中php访问sftp时需要ssh2扩展的安装

    php -v brew install homebrew/php/php55-ssh2 [实现方式] <?php $connection = ssh2_connect('192.168.0.14 ...

  10. xBIM WeXplorer xViewer的导航,相机、剖切、隐藏 等操作

    目录 基础 xBIM WeXplorer 简要介绍 xBIM WeXplorer xViewer 基本应用 xBIM WeXplorer xViewer 浏览器检查 xBIM WeXplorer xV ...