freeMaker 提示${plan4.XueHao}不被定义,求解决
错误提示:2013-9-11 12:58:44 freemarker.log.JDK14LoggerFactory$JDK14Logger error
严重:
Expression plan4.XueHao is undefined on line 87, column 88 in testWord.ftl.
The problematic instruction:
----------
==> ${plan4.XueHao} [on line 87, column 86 in testWord.ftl]
----------
Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Expression plan4.XueHao is undefined on line 87, column 88 in testWord.ftl.
at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
at freemarker.core.Expression.getStringValue(Expression.java:118)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
at freemarker.core.Environment.visit(Environment.java:208)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:208)
at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:179)
at freemarker.core.Environment.visit(Environment.java:415)
at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
at freemarker.core.Environment.visit(Environment.java:208)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:208)
at freemarker.core.Environment.process(Environment.java:188)
at freemarker.template.Template.process(Template.java:237)
at com.havenliu.document.DocumentHandler.createDoc(DocumentHandler.java:50)
at com.havenliu.document.Main.main(Main.java:10)
Expression plan4.XueHao is undefined on line 87, column 88 in testWord.ftl.
The problematic instruction:
----------
==> ${plan4.XueHao} [on line 87, column 86 in testWord.ftl]
----------
我的ftl模版如下:
[align=left] <#list table1 as plan4>
<w:tr w:rsidR="00430067" w:rsidTr="00430067">
<w:tc>
<w:tcPr>
<w:tcW w:w="4261" w:type="dxa"/>
</w:tcPr>
<w:p w:rsidR="00430067" w:rsidRDefault="00430067">
<w:r>
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
</w:rPr>
<w:t>${plan4.XueHao}</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="4261" w:type="dxa"/>
</w:tcPr>
<w:p w:rsidR="00430067" w:rsidRDefault="00430067">
<w:r>
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
</w:rPr>
<w:t>${plan4.Name}</w:t>
</w:r>
<w:bookmarkStart w:id="0" w:name="_GoBack"/>
<w:bookmarkEnd w:id="0"/>
</w:p>
</w:tc>
</w:tr>
</#list>[/align] [align=right][align=left] --------------------编程问答-------------------- 先判断下是否为空再使用
<#if plan4.XueHao ? exists>
${plan4.XueHao}
</#if> --------------------编程问答-------------------- 回复1#.但这样我也试了,这样往那个表里就写不进去内容了。怎么办? --------------------编程问答-------------------- 回复一楼,如果为空该怎办?如果不为空又该怎么办啊?求解。谢谢诶您
补充:Java , Web 开发