解决方案 »

  1.   

    我好像经常这么写
    没发现问题
    你加一个为空判断呢?
    <#if  (device.ipAddress)?exists>
    <#list device.ipAddress as pojo2>
               ${pojo2.policyTag}
               ${pojo2.policyName}
    </#list>
    </#if>
      

  2.   

    加了if以后还是报一样的错,是不是在给freemaker传参时要设置什么?
    以下是在java中调用freemaker的代码: // 要填入模本的数据文件
    Map<String, Object> dataMap = new HashMap<String, Object>();
    getData(dataMap);
    // 设置模本装置方法和路径,FreeMarker支持多种模板装载方法。可以重servlet,classpath,数据库装载,
    // 这里我们的模板是放在com.havenliu.document.template包下面
    configuration.setClassForTemplateLoading(this.getClass(),
    "/com/havenliu/document/template");
    Template t = null;
    try
    {
    t = configuration.getTemplate("GradeProtection.ftl");
    } catch (IOException e)
    {
    e.printStackTrace();
    }
    // 输出文档路径及名称
    File outFile = new File("D:/temp/outFile.doc");
    Writer out = null;
    try
    {
    out = new BufferedWriter(new OutputStreamWriter(
    new FileOutputStream(outFile)));
    } catch (FileNotFoundException e1)
    {
    e1.printStackTrace();
    }
    try
    {
    t.process(dataMap, out);
    } catch (TemplateException e)
    {
    e.printStackTrace();
    } catch (IOException e)
    {
    e.printStackTrace();
    }
      

  3.   

    问题已解决 ,感谢各位的回复!
    解决办法:
    在NDeviceLite 里加一个属性private List<ComplianceStatisticsPojo> pojos;获取时这样写:<#list device.pojos as pojo2>因为在<#list devicesList as device>这循环里写<#list device.ipAddress as pojo2>是指获取device这个对象中的ipAddress属性的值并遍历,而不是获取map中以device.ipAddress作为key的那个list对象,如果要遍历map中的那个以device.ipAddress作为key的list需要在<#list devicesList as device></#list>以外写list遍历,但这样不是我想要的结果所以在NDeviceLite 加了list属性实现双层遍历!
      

  4.   

    这是正常映射关系吧·· 对象里面都没有list集合你怎么能去遍历···
      

  5.   

    在map中有这个list,以前认为这样取的是map中的list