简体   繁体   中英

Freemarker template to check the constant value

Here is my piece of code

<#if (miscValue_index > 0)><#break></#if>
<td valign=""top"">${miscValue.propertyName!}</td>
<td width=""10px"">&nbsp;&nbsp;&nbsp;</td>
<td valign=""top"">${miscValue.propertyValue!}</td>
<td width=""10px"">&nbsp;&nbsp;&nbsp;</td>
<td valign=""top"">${miscValue.newPropertyValue!}</td>
<td width=""10px"">&nbsp;&nbsp;&nbsp;</td>

i want to check if " miscValue.propertyValue " value is UNDEFINED or valid string

miscValue.propertyValue will return a valid string or UNDEFINED. If the value returned is "UNDEFINED",i need to update "empty string" else the "orginal value" using freemarker language.Could anyone please help on this. Thanks in advance

I think you are looking for something as below,

<#if value?? >
$value
<#if/>

<#if value?? >
$value
<#else>

<#if/>

Here value can be a token that you want to verify. You can add <#else> tag if you want to print something else like blank space in case value is not valid as mentioned in second example.

您可以这样使用:

<#if variable_to_test??>not null!<#else>null!</#if>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM