首页 > 代码库 > freemarker处理哈希表的内建函数

freemarker处理哈希表的内建函数

freemarker处理哈希表的内建函数


1、简易说明

(1)map取值

(2)key取值


2、实现示例

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>freemarker处理哈希表的内建函数</title>

  </head>
  
  <body>
     <#--freemarker HashMap取值-->
	 <#assign maps={"1":"张三丰","2":"李思思","3":"张三强","4":"王五"}>
	 ${maps["3"]}
	 
	 <#assign stu={"name":"zhangsan","age":"21","sex":"man"}>
	 <#assign keys = stu?keys>
     <#list keys as key>
         ${key} = ${stu[key]};
     </#list>
  </body>
</html>

3、示例结果

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>freemarker</title>

  </head>
  
  <body>
     	 张三强
	 
         name = zhangsan;
         age = 21;
         sex = man;
  </body>
</html>