1.jstl.jar servlet.jar支持
2.jsp引入标签库
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
3.条件判断<c:choose><c:if>
<c:choose> <c:when test="${requestScope.typeFlag == 0}"> <a class="fc-a40" href="<%=Constants.ROOT + Constants.MALL_PARTS_PATH%>">配件商城</a> </c:when> <c:otherwise> <a class="fc-a40" href="<%=Constants.ROOT + Constants.MALL_AFFIX_PATH%>">汽车用品</a> </c:otherwise> </c:choose>
<c:forEach var="pic" items="${dto.pics}" varStatus="st"> <c:if test="${st.index <= 3}"> <li class="hover"> <a href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: '<%=Constants.ROOT + Constants.PARTSPATH %>${pic.picUrl}',largeimage: '<%=Constants.ROOT + Constants.PARTSPATH %>${pic.picUrl}'}"><img name="clickShowPic" src="<%=Constants.ROOT + Constants.PARTSPATH %>${pic.picUrl}" width="58" height="58" /></a> </li> </c:if> </c:forEach>
4.循环 <c:forEach>
<c:forEach var="question" items="${requestScope.li}" varStatus="st"> <%-- <li class="problem"><a href="./carQuestionAction?actionName=detail&id=${question.id}">${question.questionTitle}</a></li> --%> <li class="problem"><a href="../hudong/question/${question.id}.html">${question.questionTitle}</a></li> <li class="m-ans"><a href="#">回答(${question.carQuestionAnswerTotal})</a></li> <li class="time">${question.quotDate}</li> </c:forEach>
5.日期
<fmt:formatDate value="${dto.questionDate}" pattern="yyyy-MM-dd HH:mm:ss" />
6.函数
${fn:substring(parts.partsName,0,49)}