zoukankan      html  css  js  c++  java
  • JSTL标签库

    1、Jsp Standard Tag Library (jsp标准标签库),用来替换传统页面中的<% %>

    2、需要导包:standard.jar  jstl.jar

    3、引入标签库 

      在jsp页面中导入:

        <%@taglib  prefix=""  uri="" %>

     <%@ taglib uri=”http://java.sun.com/jsp/jstl/core” prefix=”c”%>  prefix是前缀

    4、c(core)核心标签库  介绍几个主要使用的标签

      if  注意:没有else

    <c:if test="这里写EL表达式">
      如果EL表达式成立则执行这里
    </c:if>

      choose  类似于switch

    <c:choose>
      <c:when test="EL表达式">执行语句1</c:when>
      <c:when test="EL表达式">执行语句2</c:when>
      <c:otherwise>执行语句3</c:otherwise>
    </c:choose>

      forEach

    <!-- 循环打印数字 -->
    <c:forEach begin="1" end="100" var="num">
          ${num }---    
    </c:forEach>
    <!-- 遍历数组或集合-->
    <c:forEach items="${userList}" var="u" varStatus="aaa">
          ${u.id }---${u.name }---${u.age }===${aaa.index }===${aaa.count }<br/>
    </c:forEach>
    var就是每次循环取值的引用名称,varStatus是记数,index从0开始,count从1开始

    5、fmt格式化标签库

      <%@ taglib uri=”http://java.sun.com/jsp/jstl/fmt” prefix=”fmt”%>

      <fmt:formatDate>标签:格式化时间和日期

    例如:

    <fmt:formatDate value="${current}"/>
    通过type格式指定具体的格式形式。
    <fmt:formatDate value="${d}"type="date"/>只格式成日期
    <fmt:formatDate value="${d}"type="time"/>只格式成时间
    <fmt:formatDate value="${d}"type="both"/>格式成日期+时间
    通过pattern属性指定具体的格式要求
    <fmt:formatDate value="${d}"pattern="yyyy-MM-dd"/>
  • 相关阅读:
    Xshell远程连接工具
    Linux系列之常用命令整理笔录
    板卡
    禅道Bug等级划分标准
    CPU与GPU的区别
    PICT用例组合工具简介与使用教程
    alpha测试和beta测试的区别
    性能基础知识学习之八---loadrunner中run-time setting常用功能
    性能基础知识学习之七---loadrunner压测
    性能基础知识学习之六---socket接口测试
  • 原文地址:https://www.cnblogs.com/xfdhh/p/11409177.html
Copyright © 2011-2022 走看看