freemarker基本数据类型

freemarker基本数据类型


1、基本数据类型

(1)字符串

(2)数字

(3)布尔值

(4)日期


2、展示演示样例

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>freemarker基本数据类型</title>

  </head>
  
  <body>
     <#--freemarker基本数据类型:1、字符串,2、数字,3、布尔值,4、日期-->
     <#--定义字符串-->
     <#assign str = "张三丰"/>
     ${str}
     
     <#--定义数字-->
     <#assign number = 123456/>
     ${number}
     
     <#--定义布尔值-->
     <#assign flag = true/>
     ${flag?string}
     
     <#--日期类型-->
     ${nowsday?string("yyyy-MM-dd")}
  </body>
</html>

3、測试方法

/**
	 * freemarker基本数据类型
	 * @Title:testDataType
	 * @Description:
	 * @param:
	 * @return: void
	 * @throws
	 */
	@Test
	public void testDataType()
	{
		root.put("nowsday", new Date());
		studentPrint("type.ftl");
	}

4、演示样例结果

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>freemarker基本数据类型</title>

  </head>
  
  <body>
          张三丰
     
     123,456
     
     true
     
     2014-05-31
  </body>
</html>


posted @ 2017-04-19 16:21  cxchanpin  阅读(385)  评论(0编辑  收藏  举报