简体   繁体   English

Freemarker模板检查常量值

[英]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 ”值是否未定义或有效字符串

miscValue.propertyValue will return a valid string or UNDEFINED. miscValue.propertyValue将返回有效字符串或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. 如果返回的值是“未定义”,我需要使用freemarker语言更新“空字符串”,否则需要更新“原始值”。任何人都可以提供帮助。 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. 如果要打印第二个示例中提到的值无效的空白,则可以添加<#else>标记。

您可以这样使用:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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