遇到一个问题
页面取值时,前面总是有空格,导致标题不居中,以前是这么写的。
<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>
本文解决了一个关于页面标题无法正确居中的问题。通过调整EL表达式的条件判断结构,使用<c:choose>标签替换原有的<c:if>标签,成功去除了标题前的空白字符,实现了标题的居中显示。
6481

被折叠的 条评论
为什么被折叠?



