jstldemo.jsp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  2. <%@ page import="com.lovecoding.doman.Brand" %>
  3. <%@ page import="java.util.ArrayList" %>
  4. <%@ page import="java.util.List" %><%--
  5. Created by IntelliJ IDEA.
  6. User: 武恒
  7. Date: 2023/2/6
  8. Time: 15:44
  9. To change this template use File | Settings | File Templates.
  10. --%>
  11. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  12. <html>
  13. <head>
  14. <title>Title</title>
  15. </head>
  16. <body>
  17. <%
  18. List<Brand> brands = new ArrayList<Brand>();
  19. brands.add(new Brand(1,"三只松鼠","三只松鼠",100,"三只松鼠,好吃不上火",1));
  20. brands.add(new Brand(2,"优衣库","优衣库",200,"优衣库,服适人生",0));
  21. brands.add(new Brand(3,"小米","小米科技有限公司",1000,"为发烧而生",1));
  22. pageContext.setAttribute("brands", brands);
  23. %>
  24. <h4 style="text-align: center;">商品表格</h4>
  25. <table border="1" cellspacing="0" width="800" align="center">
  26. <tr align="center">
  27. <td><b>序号</b></td>
  28. <td><b>LOGO</b></td>
  29. <td><b>商品</b></td>
  30. <td><b>企业</b></td>
  31. </tr>
  32. <c:forEach items="${brands}" var="next" >
  33. <c:if test="${next.id > 1}" >
  34. <tr align="center">
  35. <td>${next.id}</td>
  36. <td><img src="https://p0.itc.cn/images01/20210304/095a3fabfc7e48fdbcdb16e5df45d3fe.jpeg" width="30"></td>
  37. <td>${next.brandName}</td>
  38. <td>${next.companyName}</td>
  39. </tr>
  40. </c:if>
  41. </c:forEach>
  42. <c:forEach begin="0" end="10" var="i" step="1" varStatus="status" >
  43. ${i} ------ ${status.index + 1 } <br />
  44. </c:forEach>
  45. </table>
  46. </body>
  47. </html>