Posted on 2007-04-10 15:02
skycity 閱讀(4478)
評論(8) 編輯 收藏 所屬分類:
MVC框架
在應(yīng)用程序開發(fā)中,如果內(nèi)容過長,想截取一定長度字符,然后補(bǔ)充"....."
jstl1.1引入了一個(gè)fn.tld的標(biāo)簽,用于處理字符,如獲得字符length,substring,indexof,endWith,lowcase
實(shí)現(xiàn)截取字符串
如:
<c:set var="log.logTitle" value="做一個(gè)截取字符串長度的測試"
<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