Posted on 2007-04-10 15:02
skycity 閱讀(4480)
評論(8) 編輯 收藏 所屬分類:
MVC框架
在應用程序開發中,如果內容過長,想截取一定長度字符,然后補充"....."
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>
Lyyb2001