Java – date that can be empty in FreeMarker

This is part of my freemaker template:

${order.needByDate?if_exists?date}

I hope it works as follows:

>If needbydate is null, nothing is written > if it is not null, the date part is written

The above applies only to the second case What is the correct way to achieve this goal?

Solution

There may be a smarter way to do this, but the following should be done

<#if order.needByDate??>${order.needByDate?date}</#if>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>