【发布时间】:2026-01-29 09:25:02
【问题描述】:
在我的 if 语句中,我想将一个变量(JDK 1.5 枚举)与一个枚举文字进行比较。例如:
<#if type == ProblemStatisticType.BEST_SOLUTION_CHANGED>
...
</#if>
但我得到了这个例外:
freemarker.core.InvalidReferenceException: Expression ProblemStatisticType is undefined on line 430, column 87 in index.html.ftl.
at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:125)
at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:135)
我该怎么做?
【问题讨论】:
-
您也可以使用@ControllerAdvice 类,并指定一个ModelAttribute 方法,将枚举添加到模型中
标签: java freemarker