使用html模板日期站位符时出错

 

报错信息:

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:
==> date  [in template "3.html" at line 154, column 95]

----
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: ${date}  [in template "3.html" at line 154, column 93]
----

Java stack trace (for programmers):
----
freemarker.core._TemplateModelException: [... Exception message was already printed; see it above ...]

意思就是使用的date类型无法转换为String类型,对于格式无法确定

原始代码:      时间:${date}

修改为:         时间:${date?string("yyyy-MM-dd")}

此问题即可解决.

posted on 2022-04-21 14:45  一往无前!  阅读(244)  评论(0编辑  收藏  举报