JSTL中怎么利用list.size()处理IP地址 - 编程语言

这篇文章主要介绍“JSTL中怎么利用list.size()处理IP地址”,在日常操作中,相信很多人在JSTL中怎么利用list.size()处理IP地址问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”JSTL中怎么利用list.size()处理IP地址”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

得到list.size()

Java代码

${fn:length(listComment)}     ${fn:length(listComment)}

处理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>*

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>

截取时间戳

Java代码

${fn:substring(comment.time,0,19)}        ${fn:substring(comment.time,0,19)}

自动关闭模态窗口

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>

JSTL中varStatus和 var 属性一样,varStatus用于创建限定了作用域的变量。不过,由varStuts属性命名的变量并不存储当前索引值或当前元素,而是赋予 javax.servlet.jsp.jstl.core.LoopTagStatus 类的实例。该类定义了一组特性,它们描述了迭代的当前状态,下面列出了这些特性:

Java代码

  1. 特性         Getter                       描述       

  2. current    getCurrent()           当前这次迭代的(集合中的)项      

  3. index       getIndex()               当前这次迭代从 0 开始的迭代索引      

  4. count       getCount()             当前这次迭代从 1 开始的迭代计数      

  5. first          isFirst()                  用来表明当前这轮迭代是否为***次迭代的标志      

  6. last          isLast()                  用来表明当前这轮迭代是否为***一次迭代的标志      

  7. begin      getBegin()                begin 属性值       

  8. end         getEnd()                 end 属性值       

  9. step        getStep()                step 属性值       

  10.     

  11.  <c:forEach items="${listZonenews}" var="zonenews" varStatus="s">     

  12.     ${s.count}.&nbsp;${zonenews.title }     

  13.   </c:forEach>   

到此,关于“JSTL中怎么利用list.size()处理IP地址”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注云网站,小编会继续努力为大家带来更多实用的文章!

赞(0)
未经允许不得转载:主机测评网 » JSTL中怎么利用list.size()处理IP地址 - 编程语言
分享到: 更多 (0)