JSTL标签(简化JSP中java代码的书写)之if test和for each的使用

JSTL标签(简化JSP中java代码的书写)之if test和for each的使用



首先要引入坐标,并且在JSP页面上导入库

在这里插入图片描述
在这里插入图片描述
值的判断要放在{}里面,和EL表达式取出来的放在一起才可以

在这里插入图片描述

Varstatus的作用

id在数据库中是主键值,有可能因为数据的删除而导致不连续,为了在页面上显示的序号是连续的,可以使用Varstatus属性。
在这里插入图片描述
在这里插入图片描述

产生网页分页工具条的功能在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

例子:

<%--
  Created by IntelliJ IDEA.
  User: 南理工张佳成
  Date: 2021/12/12
  Time: 17:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


      <!DOCTYPE html>
      <html>
      <head>
      <meta charset="UTF-8">
      <title>Title</title>
      </head>
      <body>
      <input type="button" value="新增"><br>
      <hr>
      <table border="1" cellspacing="0" width="800">
          <tr>
              <th>序号</th>
              <th>品牌名称</th>
              <th>企业名称</th>
              <th>排序</th>
              <th>品牌介绍</th>
              <th>状态</th>
              <th>操作</th>
          </tr>


          <c:forEach items="${brands}" var="brand" varStatus="status">
          <tr>
              <td>${status.count}</td>
              <td>${brand.brandName}</td>
              <td>${brand.companyName}</td>
              <td>${brand.ordered}</td>
              <td>${brand.description}</td>

              <c:if test="${brand.status==1}">
                  <td>启用</td>
              </c:if>
              <c:if test="${brand.status!=1}">
                  <td>禁用</td>
              </c:if>
              <td><a href="#">修改</a> <a href="#">删除</a></td>
          </tr>
          </c:forEach>


      </table>

      </body>
      </html>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值