zoukankan      html  css  js  c++  java
  • jstl表达式使用方法

    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)}
  • 相关阅读:
    171. Excel Sheet Column Number (Easy)
    349. Intersection of Two Arrays (Easy)
    453. Minimum Moves to Equal Array Elements (Easy)
    657. Judge Route Circle (Easy)
    CSS笔记
    保存页面状态
    UI开发总结
    ubuntu 下配置munin
    反向代理配置
    JavaScript 高级程序设计第二版
  • 原文地址:https://www.cnblogs.com/simpledev/p/3530933.html
Copyright © 2011-2022 走看看