jstl標籤庫和區別

遇到一個問題

頁面取值時,前面總是有空格,導致標題不居中,以前是這麼寫的。

                                    <c:if test="${fn:length(data[0].name)>8}">${fn:substring(data[0].name,0,8)}...</c:if>
       		 	   <c:if test="${fn:length(data[0].name)<=8}">${fn:trim(data[0].name)}</c:if>

後來我改成這樣就可以了

                                <c:choose>
   				  	<c:when test="${fn:length(data[0].name)>8}">
   				  		${fn:substring(data[0].name,0,8)}...
   				  	</c:when>
   				  	<c:otherwise>
   				  		${fn:trim(data[0].name)}
   				  	</c:otherwise>
   				  </c:choose>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章