使用FREEMARKER的一些总结

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

问题:Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string.<format> or ?string(format) built-in with this date.
The problematic instruction:
----------
==> ${student.birthday} [on line 6, column 44 in pages/test.ftl]

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


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

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

问题:freemarker.core.ParseException: Encountered "{" at line 8, column 7 in pages/test.ftl.
Was expecting one of:
    ">" ...
    "." ...
    "[" ...
    "(" ...
    "?" ...
    "!" ...
    <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)

解决方法:
将其改写为<#if student.name=="小傻瓜!">哈哈<#else>heihei</#if>

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

问题代码:<#list list as student><#/list>

问题:freemarker.core.ParseException: Unexpected end of file reached.
Unclosed list directive.

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


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

你可能感兴趣的:(java,freemarker,cache,servlet,ext)