JSTL中截取一定长度的字符串

JSTL中截取一定长度的字符串长度,如果超过指定长度在未尾加“......”,否则返回原来字符串。

代码如下:

      <c:set var="testStr" value="做一个截取字符串长度的测试"/>
      <c:choose>
          <c:when test="${fn:length(testStr) > 10}">
              <c:out value="${fn:substring(testStr, 0, 10)}......" />
          </c:when>
         <c:otherwise>
            <c:out value="${testStr}" />
          </c:otherwise>
      </c:choose>

转自:http://blog.csdn.net/xuaa/article/details/6649541

猜你喜欢

转载自blog.csdn.net/lutinghuan/article/details/42212569