1、错误描述

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

  </head>

  <body>
     	 张三强

Expected collection or sequence. maps evaluated instead to freemarker.core.HashLiteral$SequenceHash on line 13, column 17 in map.ftl.
The problematic instruction:
----------
==> list maps as map [on line 13, column 10 in map.ftl]
----------

Java backtrace for programmers:
----------
freemarker.template.TemplateException: Expected collection or sequence. maps evaluated instead to freemarker.core.HashLiteral$SequenceHash on line 13, column 17 in map.ftl.
	at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:136)
	at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:190)
	at freemarker.core.Environment.visit(Environment.java:428)
	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
	at freemarker.core.Environment.visit(Environment.java:221)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:221)
	at freemarker.core.Environment.process(Environment.java:199)
	at freemarker.template.Template.process(Template.java:259)
	at com.you.freemarker.FreemarkerTemplate.printFtl(FreemarkerTemplate.java:77)
	at com.you.test.freemarker.FreemarkerTest.studentPrint(FreemarkerTest.java:210)
	at com.you.test.freemarker.FreemarkerTest.testMap(FreemarkerTest.java:197)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
六月 04, 2014 10:52:14 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error
严重: Template processing error: "Expected collection or sequence. maps evaluated instead to freemarker.core.HashLiteral$SequenceHash on line 13, column 17 in map.ftl."

Expected collection or sequence. maps evaluated instead to freemarker.core.HashLiteral$SequenceHash on line 13, column 17 in map.ftl.
The problematic instruction:
----------
==> list maps as map [on line 13, column 10 in map.ftl]
----------

Java backtrace for programmers:
----------
freemarker.template.TemplateException: Expected collection or sequence. maps evaluated instead to freemarker.core.HashLiteral$SequenceHash on line 13, column 17 in map.ftl.
	at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:136)
	at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:190)
	at freemarker.core.Environment.visit(Environment.java:428)
	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
	at freemarker.core.Environment.visit(Environment.java:221)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:221)
	at freemarker.core.Environment.process(Environment.java:199)
	at freemarker.template.Template.process(Template.java:259)
	at com.you.freemarker.FreemarkerTemplate.printFtl(FreemarkerTemplate.java:77)
	at com.you.test.freemarker.FreemarkerTest.studentPrint(FreemarkerTest.java:210)
	at com.you.test.freemarker.FreemarkerTest.testMap(FreemarkerTest.java:197)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Expected collection or sequence. maps evaluated instead to freemarker.core.HashLiteral$SequenceHash on line 13, column 17 in map.ftl.
The problematic instruction:
----------
==> list maps as map [on line 13, column 10 in map.ftl]
----------

Java backtrace for programmers:
----------
freemarker.template.TemplateException: Expected collection or sequence. maps evaluated instead to freemarker.core.HashLiteral$SequenceHash on line 13, column 17 in map.ftl.
	at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:136)
	at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:190)
	at freemarker.core.Environment.visit(Environment.java:428)
	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
	at freemarker.core.Environment.visit(Environment.java:221)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:221)
	at freemarker.core.Environment.process(Environment.java:199)
	at freemarker.template.Template.process(Template.java:259)
	at com.you.freemarker.FreemarkerTemplate.printFtl(FreemarkerTemplate.java:77)
	at com.you.test.freemarker.FreemarkerTest.studentPrint(FreemarkerTest.java:210)
	at com.you.test.freemarker.FreemarkerTest.testMap(FreemarkerTest.java:197)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

2、错误原因

maps不是一个序列,不能用list遍历map

 <#--freemarker HashMap取值-->
<#assign maps={"1":"张三丰","2":"李思思","3":"张三强","4":"王五"}>
${maps["3"]}

<#list maps as map>
 ${map}
</#list>

3、解决办法

先获取map中的key值,再通过key值序列遍历map

<#--freemarker HashMap取值-->
	 <#assign maps={"1":"张三丰","2":"李思思","3":"张三强","4":"王五"}>
	 ${maps["3"]}

	 <#assign keys=maps?keys>
	 <#list keys as key>
	    ${key}----${maps[key]}
	 </#list>

freemarker报错之十四的更多相关文章

  1. freemarker报错之十五

    1.错误描述 六月 04, 2014 11:04:03 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template proc ...

  2. freemarker报错之十二

    1.错误描述 六月 04, 2014 10:31:47 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template proc ...

  3. freemarker报错之十

    1.错误描述 <html> <head> <meta http-equiv="content-type" content="text/htm ...

  4. freemarker报错之四

    1.错误描述 五月 28, 2014 9:56:48 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template proce ...

  5. freemarker报错之七

    1.错误描述 五月 30, 2014 11:33:57 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template proc ...

  6. 关于SpringMVC整合freemarker报错问题

    错误信息: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'FreeMa ...

  7. freemarker写select组件报错总结(四)

    1.错误描述 <html> <head> <meta http-equiv="content-type" content="text/htm ...

  8. freemarker报错之三

    1.错误描写叙述 Expression students is undefined on line 30, column 24 in student.ftl. The problematic inst ...

  9. freemarker报错之八

    1.错误描写叙述 freemarker.core.ParseException: Encountered "string" at line 21, column 21 in typ ...

随机推荐

  1. Single-Pass Stereo Rendering for HoloLens——HoloLens的单程立体渲染

    原文网站:https://docs.unity3d.com/Manual/SinglePassStereoRenderingHoloLens.html Single-Pass Stereo Rende ...

  2. 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示

    1.打开eclipse→Windows→Preferences→Java→Editor→Content Assist 修改Auto Activation triggers for java的值为:zj ...

  3. POJ 1704 Georgia and Bob [阶梯Nim]

    题意: 每次可以向左移动一个棋子任意步,不能跨过棋子 很巧妙的转化,把棋子间的空隙看成石子堆 然后裸阶梯Nim #include <iostream> #include <cstdi ...

  4. Android开发常用的插件及工具

    1.GitHub,这个不管是做安卓还是其他,只要是开发就必上的网站,也是天朝没有墙掉为数不多的网站 2.Stack OverFlow,这个和上面一样,国外非常著名的问答网站,在上面基本上很多问题都可以 ...

  5. rsync实现数据增量备份

    环境说明: 主机ip:192.168.0.201 需备份的目录:/opt/mail 备份机器ip:192.168.0.215 1.编辑/etc/rsyncd.conf文件(etc目录不存在的话,需要手 ...

  6. 2018/1/27 Zookeeper实现分布式锁

    public class DistributedClient { // 超时时间 private static final int SESSION_TIMEOUT = 5000; // zookeep ...

  7. Html5本地存储和本地数据库

    一个网站如何能在客户的浏览器存储更多的数据呢? 在Html4的时代在浏览器端存储点网站个性化的数据,尤其是用户浏览器的痕迹,用户的相关数据等一般只能存储在Cookie中,但是大多是浏览器对于Cooki ...

  8. MySQL事务处理案例演示

    <?php $mysqli=new mysqli("localhost", "root", "123456", "xsphp ...

  9. Hive入门教程

    Hive 安装 相比起很多教程先介绍概念,我喜欢先动手装上,然后用例子来介绍概念.我们先来安装一下Hive 先确认是否已经安装了对应的yum源,如果没有照这个教程里面写的安装cdh的yum源http: ...

  10. Filezilla Server 出现Error, could not connect to server解决办法

    打开任务管理器:Win+R:services.msc找到Filezilla Server并启动服务