Rya*_*yne 5 freemarker magnolia
我一直在Magnolia 代码示例中的 FreeMarker 代码末尾看到感叹号。例如:
${content.header!}
Run Code Online (Sandbox Code Playgroud)
感叹号叫什么,它有什么作用?
感叹号称为默认值运算符。它用于在插值 ( ${...}) 返回时设置默认值null。如果未设置默认值,则返回空字符串 ( "")。
${content.header!}
<#-- Returns "" if content.header is null -->
${content.header!"Example Header"}
<#-- Returns "Example Header" if content.header is null -->
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅处理丢失的变量。
| 归档时间: |
|
| 查看次数: |
1765 次 |
| 最近记录: |