zoukankan      html  css  js  c++  java
  • 12.25 补充总结jsp标签

    注:标签引用时,需在jsp 头部添加如下语句

    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

    1、jsp-jstl-if 标签的引用

    if标签
    格式:
    <c:if test="${1==1}">
    Hello
    </c:if>
    常用属性:
    test:条件判断,操作的是域对象,接收返回结果是boolean类型的值(必要属性)
    var:限域变量名(存放在作用域中的变量名),用于接受判断结果的值 (可选属性)
    scope:限域变量名的范围(page,request,session,application)
    注意事项:
    1、标签操作一般都是域对象
    2、if标签没有else 如果需要,则需要设置完全相反的条件判断语句

    <c:if test="${1==1}">
        Hello
    </c:if>

    2、jsp-jstl choose otherwise when

    JSTL中的choose when otherwise标签的使用
    注:
    1、choose标签没有属性
    2、when标签只有一个test属性,必要的属性
    注意:
    1、choose标签和otherwise标签没有属性,而when标签必须有一个test属性
    2、choose标签中必须包含至少一个when标签,可以没有otherwise标签
    3、otherwise标签必须设置在最后一个when标签之后
    4、choose标签中智能设置when标签与otherwise标签
    5、when标签otherwise标签中可以嵌套其他标签
    6、otherwise标签会在所有的when标签不执行时才会执行
    <%
        request.setAttribute("score",999);
    %>
    <c:choose>
        <c:when test="${score<60}">
            成绩不合格
        </c:when>
        <c:when test="${score==60}">
            成绩及格
        </c:when>
        <c:when test="${score>60&&score<80}">
            成绩良好
        </c:when>
        <c:when test="${score>=80&&score<100}">
            成绩优秀
        </c:when>
        <c:otherwise>
            成绩输入错误!!
        </c:otherwise>
    </c:choose>

    3、jsp-jstl-foreach 标签的引用

    foreach:当前这次迭代从0开始的迭代索引
    count:当前这次迭代从1开始的的迭代计数
    first:用来表名带你给钱这轮迭代是否为第一次迭代的标志
    last:用来表名当前这轮迭代是否为最后一次迭代的标志
    <c:forEach items="<object>" begin="<int>" end="<int>" step="<int>"
    var="<string>"
    varStatus="<string>"
    ></c:forEach>
    1、迭代主题内容多次
    <c:forEach items="<迭代主体>" begin="<开始数>" end="<结束数>" step="<间隔数>"
    var="<限域变量名>"
    varStatus="<属性>"
    ></c:forEach>
    相当于Java中的 for。。。int 循环
    for(int i=0;i<10;i++){}
    2、循环
    <c:forEach items="<要被循环的数据>"
    var="<限域变量名>"
    ></c:forEach>

     

    <c:forEach var="i" begin="1" end="10" step="2">
        ${i}<br>
    </c:forEach>
    <table align="center" width="600" border="1" style="border-collapse: collapse">
        <tr>
            <th>名称</th>
            <th>当下成员下标</th>
            <th>当前成员循环数</th>
            <th>是否第一次循环</th>
            <th>是否最后一次循环</th>
        </tr>
        <c:forEach items="${li}" var="item" varStatus="itemp">
            <tr>
                <td>${item}</td>
                <td>${itemp.index}</td>
                <td>${itemp.count}</td>
                <td>${itemp.first}</td>
                <td>${itemp.last}</td>
            </tr>
        </c:forEach>
    </table>
  • 相关阅读:
    HTTP Error 502.5
    ubuntu 换源 aliyun
    vsdbg 下载方法 使用下载工具下载后手动安装
    Asp.NET Core Nginx Ocelot ForwardedHeaders X-Forwarded-For
    ocelot性能测试
    Hyper V 内部网络(NAT)设置 配置固定IP / DHCP
    Powershell ExecutionPolicy 执行策略
    centos ftp服务器搭建 vsftpd 匿名访问配置方法 ftp 550 Failed to open file 错误处理
    powershell与linux bash对比
    virtualbox 配置记录
  • 原文地址:https://www.cnblogs.com/lx06/p/15754926.html
Copyright © 2011-2022 走看看