前台截取 和 常用的JSTL

版权声明:帅气Dee海绵宝宝 https://blog.csdn.net/xyjcfucdi128/article/details/84614746

前台截取 :这里 ${item.colum1} 是用el取出来值  通过  .substr(a,b)进行截取 a为起始 b为截至

 var  colum0='${item.colum1}';
 colum0=colum0.substr(0,150)+"....";

个人常用的JSTL标签

1 .<c:forEach> 
用法: 可以取出 当前行数  items 为 起的别名 xxlist为集合

<c:forEach items="bean" var="xxlist" varStatus="status"> 
    ${status.count} <%--显示行数--%> 
</c:forEach> 

2 .<c:if> 

用法:test里卖写判断条件

<c:if test="">xx</c:if> 

3.<c:choose> 
用法: when 是当前判断成立时候执行,otherwise 为当不满足when的条件时候执行

<c:choose> 
 <c:when test="${a==1}"> 
  xx 
 </c:when> 
 <c:when test="${a==2}"> 
  xx 
 </c:when> 
 <c:otherwise> 
  xx 
 </c:otherwise> 
</c:choose> 

4.<c:redirect>

用法:重定向 

<c:redirect url="a.jsp">

5.<fmt:formatDate />

用法:当el取出类型为时间类型时候可以用<fmt:formatDate />转换成 你想要的时间格式需要引入的头部

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 
<fmt:formatDate value="${projectVo.createTime}" type="both" pattern="yyyy-MM-dd HH:mm:ss"/> 

猜你喜欢

转载自blog.csdn.net/xyjcfucdi128/article/details/84614746