Search code examples
springmavenjstlcout

Showing part of a string via c:out


In my application, there is a field shown on the jsp. I wrote it by using

<td>
<c:out value="${field}" />
</td>

However, I dont want everything in that value(field) to be shown. Only first 15 characters should be shown. How can I do that? I am using spring 3.1 and it is amven project. Thanks,


Solution

  • Use this:

    <c:choose>
       <c:when test="${fn:length(field) > 15}">
          ${fn:substring(field,0,10)}...
       </c:when>
      <c:otherwise>
         ${field}
      </c:otherwise>
    </c:choose>
    

    You can use to display your output, I have written here directly .