应用场景:
如新闻列表展现时,超过长度的新闻截取前几个文字,后边的用 ... 表示。如下图所示:
参考代码:
- <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>
本文介绍了一种在新闻列表中实现标题截断的方法,当新闻标题超过13个字符时,仅显示前13个字符并以省略号代替剩余部分。通过这种方式,可以有效地节省显示空间,并保持列表的整洁。文中提供了具体的JSP页面代码示例。
507

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



