FreeMarker template error:
Can't convert the date-like value to string because it isn't known if it's a date (no time part), time or date-time value.
The blamed expression:
==> (time)!'' [in template "strTpl" at line 1, column 3]
----
Tip: Use ?date, ?time, or ?datetime to tell FreeMarker the exact type.
----
Tip: If you need a particular format only once, use ?string(pattern), like ?string('dd.MM.yyyy HH:mm:ss'), to specify which fields to display.
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: ${(time)!""} [in template "strTpl" at line 1, column 1]
----
Java stack trace (for programmers):
----
freemarker.core._TemplateModelException: [... Exception message was already printed; see it above ...]
at freemarker.core._MessageUtil.newCantFormatUnknownTypeDateException(_MessageUtil.java:301)
at freemarker.core.Environment.getTemplateDateFormat(Environment.java:1660)
at freemarker.core.Environment.getTemplateDateFormat(Environment.java:1645)
at freemarker.core.evalUtil.coerceModelToStringOrMarkup(evalUtil.java:380)
at freemarker.core.evalUtil.coerceModelToStringOrMarkup(evalUtil.java:358)
at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:100)
at freemarker.core.DollarVariable.accept(DollarVariable.java:63)
at freemarker.core.Environment.visit(Environment.java:330)
at freemarker.core.Environment.process(Environment.java:309)
at freemarker.template.Template.process(Template.java:384)
at com.xfs.micro.common.module.utils.tools.FreemarkerTemplateUtil.processFreemarker(FreemarkerTemplateUtil.java:32)
at com.xfs.micro.log.service.buried.filter.BuriedPointEvidenceFilter.main(BuriedPointEvidenceFilter.java:90)
Caused by: freemarker.core.UnknownDateTypeFormattingUnsupportedException: Can't convert the date-like value to string because it isn't known if it's a date (no time part), time or date-time value.
at freemarker.core.Environment.getTemplateDateFormat(Environment.java:1722)
at freemarker.core.Environment.getTemplateDateFormat(Environment.java:1492)
at freemarker.core.Environment.getTemplateDateFormat(Environment.java:1658)
... 10 more
按报错提示信息修改问题:
${requestInfo.requestTime?string('yyyy-MM-dd HH:mm:ss.SSS')}
不可以写成${requestInfo.requestTime?string("yyyy-MM-dd HH:mm:ss.SSS")}否则还会报转义字符的错误
或者
${requestInfo.requestTime?date}
${requestInfo.requestTime?time}
${requestInfo.requestTime?datetime}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)