在使用freemarker时遇到session取值报错问题。求大神看看
爱喝甜咖啡 2017-09-22 10:52:32 报错信息:
FreeMarker template error:
The following has evaluated to null or missing:
==> Session [in template "estudy/indexThree/indexArea/index-mainMenu.ftl" at line 9, column 6]
----
Tip: If the failing expression is known to be legally refer to something that's null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: #if Session["province_plat_form"]?? [in template "estudy/indexThree/indexArea/index-mainMenu.ftl" at line 9, column 1]
- Reached through: #include "/estudy/indexThree/indexAre... [in template "estudy/common/common-pages.ftl" in macro "headerIndexThree" at line 73, column 5]
- Reached through: @pages.headerIndexThree curIndex="\${... [in template "estudy/indexThree/estudyIndexThree.ftl" at line 21, column 9]
----
Java stack trace (for programmers):
----
freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
页面的显示:
<#if Session["province_plat_form"]??>
<a href="${request.contextPath}/estudy/selfCourse/selfCourseCenter.action" <#if curIndex?default('')==MOD_INDEX_SELF_COURSE>class="current"</#if>>自建课程</a>
<#else>
</#if>
FreeMarker settings:
#0 is for development only! Use higher value otherwise.
template_update_delay=0
locale=zh_CN
default_encoding=UTF-8
number_format=0.##
date_format=yyyy-MM-dd
template_exception_handler=ignore
版本号
freemarker-2.3.22.jar
程序用的是 spring struts2