freemarker基本数据类型
假如你现在还在为自己的技术担忧,假如你现在想提升自己的工资,假如你想在职场上获得更多的话语权,假如你想顺利的度过35岁这个魔咒,假如你想体验BAT的工作环境,那么现在请我们一起开启提升技术之旅吧,详情请点击http://106.12.206.16:8080/qingruihappy/index.html
1、基本数据类型
(1)字符串
(2)数字
(3)布尔值
(4)日期
2、展示示例
1 <html> 2 <head> 3 <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 4 <title>freemarker基本数据类型</title> 5 6 </head> 7 8 <body> 9 <#--freemarker基本数据类型:1、字符串,2、数字,3、布尔值,4、日期--> 10 <#--定义字符串--> 11 <#assign str = "张三丰"/> 12 ${str} 13 14 <#--定义数字--> 15 <#assign number = 123456/> 16 ${number} 17 18 <#--定义布尔值--> 19 <#assign flag = true/> 20 ${flag?string} 21 22 <#--日期类型--> 23 ${nowsday?string("yyyy-MM-dd")} 24 </body> 25 </html>
3、测试方法
1 /** 2 * freemarker基本数据类型 3 * @Title:testDataType 4 * @Description: 5 * @param: 6 * @return: void 7 * @throws 8 */ 9 @Test 10 public void testDataType() 11 { 12 root.put("nowsday", new Date()); 13 studentPrint("type.ftl"); 14 }
4、示例结果
1 <html> 2 <head> 3 <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 4 <title>freemarker基本数据类型</title> 5 6 </head> 7 8 <body> 9 张三丰 10 11 123,456 12 13 true 14 15 2014-05-31 16 </body> 17 </html>