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 ...
随机推荐
- ABP官方文档翻译 7.2 Hangfire集成
Hangfire集成 介绍 ASP.NET Core集成 ASP.NET MVC 5.x集成 面板授权 介绍 Hangfire是一个综合的后台job管理器.你可以 把它集成到ABP,用来取代默认的后台 ...
- Springboot security cas整合方案-原理篇
前言:网络中关于Spring security整合cas的方案有很多例,对于Springboot security整合cas方案则比较少,且有些仿制下来运行也有些错误,所以博主在此篇详细的分析cas原 ...
- 设计模式之“Decorator”注疏#02
装饰模式在某种意义上来说也是挺原始的, 它首先需要一个你被装饰的基础类, 再来是需要一个基于这个基础类的原始包装器,可以看作是其它包装器的基础类 进而通过继承这个包装器,来构建出多个具有各自功能的特定 ...
- python进行各类API的使用
前言: 献上歌曲一首: 因为快要上学了,昨天晚上熬夜.然后今天早上起床 没有什么精神.吃完午饭后开始思考今天写什么好呢 然后逛着逛着逛到了一个API网站.感觉还不错就爬了 0x01: 环境:windo ...
- python配置apache的web服务器方法(python的CGI配置)
先大概介绍一下:Python CGI编程 什么是CGI CGI 目前由NCSA维护,NCSA定义CGI如下: CGI(Common Gateway Interface),通用网关接口,它是一段程序,运 ...
- shell脚本实现anisble客户端脚本分发和密钥授权配置
##############################Deploy ansible client shell######################## echo "start d ...
- [bzoj2286][Sdoi 2011]消耗战
[bzoj2286]消耗战 标签: 虚树 DP 题目链接 题解 很容易找出\(O(mn)\)的做法. 只需要每次都dp一遍. 但是m和n是同阶的,所以这样肯定会T的. 注意到dp的时候有很多节点是不需 ...
- [原创]CentOS7安装远程工具teamviewer12
系统环境:CentOS 7.0.1 1.下载安装# wget https://dl.tvcdn.de/download/version_12x/teamviewer_12.0.85001.i686.r ...
- url路径去掉两个opencms
采用刚刚的方法安装OpenCMS之后,站点url中会存在两个opencms,造成访问url路径过长,下面讲解一种去掉两个opencms的方法. 1.去掉第一个opencms 安装时采用ROOT安装,即 ...
- MySQL Server 5.0安装教程
相信很多朋友刚开始接触mysql数据库服务器,下面是mysql的安装教程,步骤明细也有详细的说明. 工具/原料 mysql MySQL安装的图解 1 打开下载的mysql安装文件mysql-5 ...