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)}
  • 相关阅读:
    c# vs2010 excel 上传oracle数据
    Viola-Jones人脸检測
    apache commons-configuration包读取配置文件
    linux 读取文件
    linux 统计某个文件的行数
    linux 判空处理
    linux 查看某个目录下文件的数量
    nginx 配置文件正确性测试
    使用postman上传excel文件测试导入excel
    java 反射获取字段为List类型中的泛型类型
  • 原文地址:https://www.cnblogs.com/simpledev/p/3530933.html
Copyright © 2011-2022 走看看