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)}
  • 相关阅读:
    2020牛客暑期多校(三)
    贪心算法
    高级搜索题集
    状态压缩dp
    [kuangbin带你飞]专题二 搜索进阶
    [kuangbin带你飞]专题一 简单搜索
    HDU 1695 GCD(求两区间的互质数对+容斥原理)
    UVA 10200 Prime Time(简单素数判定预处理)
    HDU 1452 FZU 1053 Happy 2004(逆元函数+因子和函数+大指数取模化简公式)
    低三位的数是8的倍数就可以被8整除
  • 原文地址:https://www.cnblogs.com/simpledev/p/3530933.html
Copyright © 2011-2022 走看看