遇到一個問題
頁面取值時,前面總是有空格,導致標題不居中,以前是這麼寫的。
<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>