zoukankan      html  css  js  c++  java
  • freemaker问题整理

    本文是项目中遇到的freemaker问题的小总结:

      一、后台列表页某一字段过长,展示起来会换行不好看,现在需要对该字段进行字符串截取,所以参考   夏末的秋    的字符串截取方法的文章(https://www.cnblogs.com/m01qiuping/p/6425041.html),找到字符串截取 方法:

    ${"asddfdsd"?substring(0,20)} <#-- 从索引为0位置开始截取,到索引为20位置结束不包括20>   
      本以为这样截取前20个字符就可以了,谁知道竟然报错了,原因是当字符串不够20个字符时,就取不到第20位了,所以考虑到要先判断字符串的长度,再进行截取,所以经过查找找到了
    <#if eduQuestion.question?length gt 50>
      长度大于50
    </#if>
    这个方法,解决了我的问题,最终写法为:
    <#if (eduQuestion.question)??>
    <#if eduQuestion.question?length gt 50>
    ${eduQuestion.question?substring(0,50)}...
    <#else>
    ${eduQuestion.question}
    </#if>
    </#if>
  • 相关阅读:
    AddParent
    AddChild
    贝塞尔曲线代码
    顶点纹理shader
    抽象方法与抽象类
    Application类
    布局组件
    C#单例和Unity单例
    Unity&UGUI
    Json解析
  • 原文地址:https://www.cnblogs.com/yz820/p/10100735.html
Copyright © 2011-2022 走看看