jsp页面显示问题

一、在jsp页面的表格中,如果有表格中的某一个元素 内容太长,需要截取显示,方法如下:

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

……

<th  width="16%">描述</th>

……

<td>

    <c:if test="${fn:length(item.desc)>50}">${fn:substring(item.desc, 0, 50)}...</c:if>
    <c:if test="${fn:length(item.desc)<=50}">${item.desc}</c:if>
</td>

判断显示元素的长度是否大于50,如果大于50,则截取前50个字符,后面有… 表示。

原文地址:https://www.cnblogs.com/z360519549/p/5760409.html