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设计模式---单例模式的几种实现方式比较
1.延迟实例化方式:(懒汉模式) public class Singleton { private static Singleton uniqueInstance; private Singleton ...
- ansible playbook实践(二)-基础相关命令
ansible相关的命令: ansible 用来执行ansible管理命令 ansible-doc 用来获取模块的帮助文档 ansible-playbook 当有众多任务时,可编写成playbook ...
- 洛谷 [P1198] 最大数
首先这是一道线段树裸题,但是线段树长度不确定,那么我们可以在建树的时候,将每一个节点初始化为-INF,每次往队尾加一个元素即一次单节点更新,注意本题的数据范围,其实并不用开 long long,具体请 ...
- BZOJ 2938: [Poi2000]病毒 [AC自动机 拓扑排序]
2938: [Poi2000]病毒 题意:判断是否存在无限长的不含模式串的字符串.只有01. 建出套路DP的转移图,判断有环就行了 练习一下拓扑排序 #include <iostream> ...
- 在ConcurrentModificationException异常上的联想
1.什么是ConcurrentModificationException? 大家都听说过快速报错fast-fail吧,fast-fail的发生就是说明发生了ConcurrentModification ...
- 使用websocket实现在线聊天功能
很早以前为了快速达到效果,使用轮询实现了在线聊天功能,后来无意接触了socket,关于socket我的理解是进程间通信,首先要有服务器跟客户端,服务的启动监听某ip端口定位该进程,客户端开启socke ...
- 10位时间戳转为C#格式时间
/// <summary> /// 10位时间戳转为C#格式时间 /// </summary> /// <param name=”timeStamp”></p ...
- qt程序启动画面
- Promise对象的简单用法
要了解一个东西,首先要从,它是什么.用来做什么以及怎么取用它这三个方面来了解. 首先,promise是什么? 我们来参考一下MDN对它的定义: Promise 对象用于一个异步操作的最终完成(或失败) ...
- 【JavaWeb】c3p0连接池与MySQL
正文之前 在之前的文章讲到了传统的JDBC连接MySQL的方式,但是这样的方式在进行多个连接时,就显得效率低下,明显不如连接池的效率,所以我们这次来讲解一下JDBC连接池之一:c3p0 正文 1. 准 ...