<#list list1 as list>
<#if (list.title?length>15)>
${list.title[0..15]?default("")}
<#else>
${list.title?default("")}
</#if>
</#list>
如果实际长度没有13那么长的话加多个if
Template Author's Guide/Expressions.
You can nest if directives (of course):
| |||
Note
How to test if x is greater than 1? <#if x > 1> will be wrong, as FreeMarker will interpret the first > as the end of the tag. Thus, either write <#if (x > 1)> or <#if x > 1>.
本文介绍了使用Freemarker模板引擎进行字符串截取的方法。通过示例代码展示了如何根据字符串长度进行条件判断并实现字符串的截取显示。此外,还提供了嵌套if指令的用法及注意事项。
741

被折叠的 条评论
为什么被折叠?



