freemarker如何遍历HashMap
查询资料有以下两种方法:
1、
<#if appMap?exists>
<#list appMap?keys as key>
key:${key}
value:${appMap.get(key)}
</#list>
</#if>
2、
<#list testMap.keySet() as testKey>
<option value="${testKey}" >
${testMap.get(testKey)}
</option>
</#list>
但是需要在spring-mvc.xml文件里配置freemarkerSettings
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/view/"/>
<property name="freemarkerSettings">
<props>
<prop key="object_wrapper">freemarker.ext.beans.BeansWrapper</prop>
</props>
</property>
</bean>
而且这个配置成功之后 第一种方式是不可以的 第二种是可以成功显示的
freemarker如何遍历HashMap的更多相关文章
- java 中遍历hashmap 和hashset 的方法
一.java中遍历hashmap: for (Map.Entry<String, Integer> entry : tempMap.entrySet()) { String ...
- 使用多种方式实现遍历HashMap
今天讲解的主要是使用多种方式来实现遍历HashMap取出Key和value,首先在java中如果想让一个集合能够用for增强来实现迭代,那么此接口或类必须实现Iterable接口,那么Iterable ...
- Freemarker中遍历List以及内置函数使用
在Freemarker应用中经常会遍历List获取需要的数据,并对需要的数据进行排序加工后呈现给用户. 那么在Freemarker中如何遍历List,并对List中数据进行适当的排序呢?一. Free ...
- [Java] 遍历HashMap和HashMap转换成List的两种方式
遍历HashMap和HashMap转换成List /** * convert the map to the list(1) */ public static void main(String[] ...
- java遍历Hashmap/Hashtable的几种方法
一>java遍历Hashtabe: import java.util.Hashtable; import java.util.Set; public class HashTableTest { ...
- java遍历hashMap、hashSet、Hashtable
一.遍历HashMap Map<Integer, String> map = new HashMap<Integer, String>(); 方法一:效率高 for(Entry ...
- Java遍历HashMap并修改(remove)(转载)
遍历HashMap的方法有多种,比如通过获取map的keySet, entrySet, iterator之后,都可以实现遍历,然而如果在遍历过程中对map进行读取之外的操作则需要注意使用的遍历方式和操 ...
- 四种遍历hashMap的方法及比较
学习怎样遍历Java hashMap及不同方法的性能. // hashMap的遍历 public void testHashMap() { Map<String, String> map ...
- Java遍历HashMap并修改(remove)
遍历HashMap的方法有多种,比如通过获取map的keySet, entrySet, iterator之后,都可以实现遍历,然而如果在遍历过程中对map进行读取之外的操作则需要注意使用的遍历方式和操 ...
随机推荐
- 0506团队项目-Scrum 项目1.0
题目 1.应用NABCD模型,分析你们初步选定的项目,充分说明你们选题的理由. 2.录制为演说视频,上传到视频网站,并把链接发到团队博客上. 团队项目选题 金融工具:复利计算与投资记录项目继续升级,开 ...
- C# 生成BMP图片
;i<;i++) { Bitmap bmp=new Bitmap(this.pictureBox1.Image); Graphics g=Graphics.FromImage((Image)bm ...
- 重新想象 Windows 8.1 Store Apps 系列文章索引
[源码下载] [重新想象 Windows 8 Store Apps 系列文章] 重新想象 Windows 8.1 Store Apps 系列文章索引 作者:webabcd 1.重新想象 Windows ...
- Verilog学习笔记简单功能实现(一)...............D触发器
module D_flop(data,clk,clr,q,qb); input data,clk,clr; output q,qb; wire a,b,c,d,e,f,ndata,nclk; nand ...
- Oracle 中 call 和 exec的区别
今天发现了一个小东西,觉得很有意思,查找了一些资料,跟大家分享一下: 在sqlplus中: 在第三方提供的工具(如:plsqldev) 总结: exec是sqlplus的命令,只能在sqlplus中使 ...
- PHP imagecopyresampled 参数图示
- ASP.NET MVC 微信公共平台开发之验证消息的真实性
ASP.NET MVC 微信公共平台开发 验证消息的真实性 在MVC Controller所在项目中添加过滤器,在过滤器中重写 public override void OnActionExecuti ...
- Spark中的RDD操作简介
map(func) 对数据集中的元素逐一处理,变为新的元素,但一个输入元素只能有一个输出元素 scala> pairData.collect() res6: Array[Int] = Array ...
- 为什么Android应该根据屏幕分辨率来加载不同的图片文件
1.图片在xxhdpi,手机是hdpi的 我们有一个手机是hdpi的.我们还有一个图片,我们把他放在xxhdpi下.当手机显示的时候,系统会去hdpi中找,发现没有图片,最终在xxhpi中找到.终于找 ...
- Android WebView 获取网页的标题
final TextView txtTitle = (TextView) findViewById(R.id.txtTitle); final WebView webView = (WebView)f ...