应用场景:
如新闻列表展现时,超过长度的新闻截取前几个文字,后边的用 ... 表示。如下图所示:
参考代码:
- <c:forEach items="${newslist}" var="news" varStatus="vs">
- <li>
- <a href="${ctx}/news/newsQueryById.html?id=${news.id}">
- <span>
- ${fn:substring(news.writetime,0,10)}
- </span>
- <c:if test="${fn:length(news.title)>'13'}">
- ${fn:substring(news.title,0,13)}...
- </c:if>
- <c:if test="${fn:length(news.title)<='13'}">
- ${news.title}
- </c:if>
- </a>
- </li>
- </c:forEach>