日期:2014-05-16  浏览次数:20349 次

jstl标签显示指定长度字符串
在应用程序开发中,如果内容过长,想截取一定长度字符,然后补充"....."
jstl1.1引入了一个fn.tld的标签,用于处理字符,如获得字符length,substring,indexof,endWith,lowcase
实现截取字符串
如:
<c:set var="log.logTitle" value="做一个截取字符串长度的测试"
<c:choose>
    <c:when test="${fn:length(log.logTitle) > 10}">
     <c:out value="${fn:substring(log.logTitle, 0, 10)}......" />
    </c:when>
    <c:otherwise>
     <c:out value="${log.logTitle}" />
    </c:otherwise>
   </c:choose>