开发者

How to avoid null when formatting value

开发者 https://www.devze.com 2023-01-07 06:08 出处:网络
${date?string(\'yyyy-MM-dd\')} if date is null, freemarker will raise a exception here is a solution <#if date??>${date开发者_JAVA百科?string(\'yyyy-MM-dd\')}</#if>
${date?string('yyyy-MM-dd')}

if date is null, freemarker will raise a exception

here is a solution

<#if date??>${date开发者_JAVA百科?string('yyyy-MM-dd')}</#if>

but this code is ugly,is there any shortcut like ${date!} ?


You can write

${(p.bd?string("dd/MM/yyyy"))!}
0

精彩评论

暂无评论...
验证码 换一张
取 消