在开发工程中,往往会遇到表格中只能放少量信息,而从数据库中获取到的字符串的长度又比较大,此时用c:if 便可解决,
<%@ taglib uri="htp://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="htp://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="htp://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<c:if test="${fn:length(item.connext) > 30}">${fn:substring(item.connext, 0, 30)}...... </c:if>
类别 运算符
算术运算符 + 、 - 、 * 、 / (或 div )和 % (或 mod )
关系运算符 == (或 eq )、 != (或 ne )、 < (或 lt )、 > (或 gt )、 <= (或 le )和 >= (或 ge )
逻辑运算符 && (或 and )、 || (或 or )和 ! (或 not )
验证运算符 empty
小例子:
<tr <c:if test="${status.count%2==0}">bgcolor="#CCCCFE"</c:if> align="left">
xxx
</tr>