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