JSTL 字符串长度判断并截取
2017-09-28 00:00
197 查看
应用场景:
如新闻列表展现时,超过长度的新闻截取前几个文字,后边的用 ... 表示。如下图所示:
参考代码:
[html] view plain copy
<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>
如新闻列表展现时,超过长度的新闻截取前几个文字,后边的用 ... 表示。如下图所示:
参考代码:
[html] view plain copy
<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>
相关文章推荐
- JSTL 字符串长度判断并截取
- JSTL 字符串长度判断并截取
- JSTL中截取一定长度的字符串
- JS判断字符串字节数并截取长度的方法
- PHP针对中英文混合字符串长度判断及截取方法
- 自定义EL函数解决JSTL标签不足之处——按字节长度截取字符串
- C#判断中英文混合字符串长度及截取函数
- 自定义EL函数解决JSTL标签不足之处——按字节长度截取字符串
- JS~字符串长度判断,超出进行自动截取(支持中文)
- struts s:if 截取字符串,判断字符串长度
- Thinkphp 截取字符串和判断字符串长度
- jstl截取字符串超出长度用...代替
- JSTL中截取一定长度的字符串长度,如果超过指定长度在未尾加“......”,否则返回原来字符串。
- JS~字符串长度判断,超出进行自动截取(支持中文)
- oracle操作字符串:拼接、替换、截取、查找、长度、判断
- JS~字符串长度判断,超出进行自动截取(支持中文)
- Jstl取得字符串长度及截取字符串
- PHP针对中英文混合字符串长度判断及截取方法示例
- El表达式的判断字符串的长度和截取,日期时间的格式化
- js--小demo--字符串长度判断,超出进行自动截取(支持中文)