freemarker之include指令
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指令的更多相关文章
- freemarker之include指令(九)
		
freemarker之include指令 1.父页面ftl <html> <head> <meta http-equiv="content-type" ...
 - FreeMarker之FTL指令
		
assign指令 此指令用于在页面上定义一个变量 (1)定义简单类型: <#assign linkman="周先生"> 联系人:${linkman} (2)定义对象类型 ...
 - 浅谈JSP中include指令与include动作标识的区别
		
JSP中主要包含三大指令,分别是page,include,taglib.本篇主要提及include指令. include指令使用格式:<%@ include file="文件的绝对路径 ...
 - JSP(include指令与<jsp:include>动作的区别)
		
<%@ page language= "java" contentType="text/html;charset=UTF-8" %><html ...
 - jsp include指令
		
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"% ...
 - include指令和include标签的区别
		
区别 类别 语法 发生作用时间 包含的内容 转化成Servlet 编译时间 运行时间 include指令 <%@ include file="" %> 页面交换 实际内 ...
 - 使用-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 ...
 - include动作标记和include指令标记学习笔记
		
我的jsp学习参考书是耿祥义,张跃平编著的jsp大学使用教程这本书,我也向大家推荐这本书,我觉得这本书适合我的学习方式,知识的讲解透彻易懂. include指令标记 ...
 - Java学习-035-JavaWeb_004 -- JSP include 指令
		
inclue 指令是将不同的文件插入到 JSP 网页中,这些文件可以是文本文件.HTML文件.JSP 文件,指令语法如下: <%@include file="相对路径"%&g ...
 
随机推荐
- JAVA并发编程学习笔记------对象的可见性及发布逸出
			
一.非原子的64位操作: 当线程在没有同步的情况下读取变量时,可能会得到一个失效值,但至少这个值是由之前某个线程设置的值,而不是一个随机值,这种安全性保证被称为最低安全性.最低安全性适用于绝大多数变量 ...
 - mybatis No enum const class org.apache.ibatis.type.JdbcType.Integer
			
mybatis报错:没有Integer这个类型的jdbcType值 原因:mybatis配置重的jdbaType类型要是大写的 如图所示:
 - Tomcat学习
			
一:项目默认部署路径: eclipse中,默认new一个server,项目默认会部署在:workspace\(工作空间)\.metadata\.plugins\org.eclipse.wst.serv ...
 - 下载vlc遭遇网络劫持
			
一次偶然的机遇,在公司下载"vlc播放器",下载之后安装完就变成了"搜狗手机助手".而且连续几次下载都是这样,我以为是我安装了搜狗输入法的缘故. ...
 - Matplotlib快速入门笔记
			
我正以Python作为突破口,入门机器学习相关知识.出于机器学习实践过程中的需要,快速了解了一下matplotlib绘图库.下图是我学习过程中整理的一些概念. 本文将以该图为线索梳理相关概念. 简介 ...
 - BZOJ 3530: [Sdoi2014]数数 [AC自动机 数位DP]
			
3530: [Sdoi2014]数数 题意:\(\le N\)的不含模式串的数字有多少个,\(n=|N| \le 1200\) 考虑数位DP 对于长度\(\le n\)的,普通套路DP\(g[i][j ...
 - BZOJ 1061: [Noi2008]志愿者招募 [单纯形法]
			
传送门 题意: 长为$n$的序列,第$i$位至少$b_i$,$m$种区间使$[l_i,r_i]+1$代价为$a_i$ 求满足的最小花费 复习单纯形法重做一遍 原始问题$m$个变量$n$个约束,$a_{ ...
 - IOS教程视频汇总
			
使用StoryBoard做iOS UI界面跳转
 - [Python Study Notes]匿名函数
			
Python 使用 lambda 来创建匿名函数. lambda这个名称来自于LISP,而LISP则是从lambda calculus(一种符号逻辑形式)取这个名称的.在Python中,lambda作 ...
 - 关于Apache配置虚拟主机后在局域网中让其他电脑访问
			
#-----------adxssp------------# NameVirtualHost *:80 <VirtualHost *:80> ServerName www.b.com D ...