freemarker报错:Tip: If the failing expression is known to be legally null/missing, either specify a de

来源:互联网 发布:网络彩票开售最新进展 编辑:程序博客网 时间:2024/05/16 04:00

freemarker报错:Tip: If the failing expression is known to be legally null/missing, either specify a default value with 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 parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??



大致意思是所写的表达式应判定不为空或者指定一个默认值,貌似ftl的<#if>判断一般都一定要判断一下不能为空

错误写法(后台会报错,实际上可以允许):

</pre><p><pre name="code" class="html"><span style="font-size:18px;"><#if lists?? && lists?size gt 0><#list lists as list><option value="${list.id}" <#if outbean.id == '${list.id}'> selected="selected" </#if> >${list.name!''}</option></#list></#if></span>

纠正写法:

<#if lists?? && lists?size gt 0><#list lists as list><option value="${list.id}" <#if (outbean.id!'') == '${list.id}'> selected="selected" </#if> >${list.name!''}</option></#list></#if>


0 0
原创粉丝点击