得到list.size()
Java代码
复制
${fn:length(listComment)} ${fn:length(listComment)}
1.
2.
处理IP地址
Java代码
复制
<c:forTokens var="ip" items="${comment.ip}" delims="." begin="0" end="2">${ip}.</c:forTokens>* <c:forTokens var="ip" items="${comment.ip}" delims="." begin="0" end="2">${ip}.</c:forTokens>*
1.
2.
JSTL标签显示指定长度字符串
Java代码
复制
<c:set var="log.logTitle" value="做一个截取字符串长度的测试" <c:choose> <c:when test="${fn:length(log.logTitle) > 10}"> <c:out value="${fn:substring(log.logTitle, 0, 10)}......" /> </c:when> <c:otherwise> <c:out value="${log.logTitle}" /> </c:otherwise> </c:choose> <c:set var="log.logTitle" value="做一个截取字符串长度的测试" <c:choose> <c:when test="${fn:length(log.logTitle) > 10}"> <c:out value="${fn:substring(log.logTitle, 0, 10)}......" /> </c:when> <c:otherwise> <c:out value="${log.logTitle}" /> </c:otherwise> </c:choose>
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
截取时间戳
Java代码
复制
${fn:substring(comment.time,0,19)} ${fn:substring(comment.time,0,19)}
1.
2.
自动关闭模态窗口
Java代码
复制
<c:if test="${success=='ok'}" > <script type="text/javascript"> alert("评论发表成功"); parent.parent.location.reload(); </script> </c:if> <c:if test="${success=='ok'}" > <script type="text/javascript"> alert("评论发表成功"); parent.parent.location.reload(); </script> </c:if>
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
JSTL中varStatus和 var 属性一样,varStatus用于创建限定了作用域的变量。不过,由varStuts属性命名的变量并不存储当前索引值或当前元素,而是赋予 javax.servlet.jsp.jstl.core.LoopTagStatus 类的实例。该类定义了一组特性,它们描述了迭代的当前状态,下面列出了这些特性:
Java代码
复制
特性 Getter 描述 current getCurrent() 当前这次迭代的(集合中的)项 index getIndex() 当前这次迭代从 0 开始的迭代索引 count getCount() 当前这次迭代从 1 开始的迭代计数 first isFirst() 用来表明当前这轮迭代是否为***次迭代的标志 last isLast() 用来表明当前这轮迭代是否为***一次迭代的标志 begin getBegin() begin 属性值 end getEnd() end 属性值 step getStep() step 属性值 <c:forEach items="${listZonenews}" var="zonenews" varStatus="s"> ${s.count}. ${zonenews.title } </c:forEach>
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
【编辑推荐】