使用FREEMARKER的一些总结

freemarkerJavaEXTCacheServlet.

问题代码:${student.birthday},STUDENT中BIRTHDAY为DATE类型的

问题:Can'tconvertthedatetostring,becauseitisnotknownwhichpartsofthedatevariableareinuse.Use?date,?timeor?datetimebuilt-in,or?string.<format>or?string(format)built-inwiththisdate.

Theproblematicinstruction:

----------

==>${student.birthday}[online6,column44inpages/test.ftl]

解决方法:${student.birthday}改为${student.birthday?string('yyyy-MM-ddHH:mm:ss')}

======================================================================

问题代码:<#if${student.name}=="小傻瓜!">哈哈<#else>heihei</#if>

问题:freemarker.core.ParseException:Encountered"{"atline8,column7inpages/test.ftl.

Wasexpectingoneof:

">"...

"."...

"["...

"("...

"?"...

"!"...

<TERMINATING_EXCLAM>...

"??"...

"+"...

"-"...

"*"...

"/"...

"%"...

"!="...

"="...

"=="...

">="...

<ESCAPED_GTE>...

">"...

<ESCAPED_GT>...

<LESS_THAN_EQUALS>...

<LESS_THAN>...

".."...

<AND>...

<OR>...

freemarker.core.FMParser.generateParseException(FMParser.java:4697)

freemarker.core.FMParser.jj_consume_token(FMParser.java:4568)

freemarker.core.FMParser.If(FMParser.java:1171)

freemarker.core.FMParser.FreemarkerDirective(FMParser.java:2372)

freemarker.core.FMParser.Content(FMParser.java:2618)

freemarker.core.FMParser.OptionalBlock(FMParser.java:2786)

freemarker.core.FMParser.Root(FMParser.java:2958)

freemarker.template.Template.<init>(Template.java:149)

freemarker.cache.TemplateCache.loadTemplate(TemplateCache.java:448)

freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:361)

freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:235)

freemarker.template.Configuration.getTemplate(Configuration.java:487)

freemarker.template.Configuration.getTemplate(Configuration.java:459)

freemarker.ext.servlet.FreemarkerServlet.process(FreemarkerServlet.java:410)

解决方法:

将其改写为<#ifstudent.name=="小傻瓜!">哈哈<#else>heihei</#if>

======================================================================

问题代码:<#listlistasstudent><#/list>

问题:freemarker.core.ParseException:Unexpectedendoffilereached.

Unclosedlistdirective.

解决方法:<#listlistasstudent></#list>((*^__^*)嘻嘻……,不好意思,写错标签了!)

相关推荐