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>

 

posted @ 2016-01-25 15:05  星辰之力  阅读(1298)  评论(0编辑  收藏  举报