brands.jsp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <%@ page import="com.lovecoding.doman.Brand" %>
  2. <%@ page import="java.util.ArrayList" %>
  3. <%@ page import="java.util.List" %>
  4. <%@ page import="java.util.Iterator" %><%--
  5. Created by IntelliJ IDEA.
  6. User: 武恒
  7. Date: 2023/2/6
  8. Time: 14:42
  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. // 查询数据库
  19. List<Brand> brands = new ArrayList<Brand>();
  20. brands.add(new Brand(1,"三只松鼠","三只松鼠",100,"三只松鼠,好吃不上火",1));
  21. brands.add(new Brand(2,"优衣库","优衣库",200,"优衣库,服适人生",0));
  22. brands.add(new Brand(3,"小米","小米科技有限公司",1000,"为发烧而生",1));
  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. <%
  33. Iterator<Brand> iterator = brands.iterator();
  34. while ( iterator.hasNext() ) {
  35. Brand next = iterator.next();
  36. %>
  37. <tr align="center">
  38. <td><%=next.getId()%></td>
  39. <td><img src="https://p0.itc.cn/images01/20210304/095a3fabfc7e48fdbcdb16e5df45d3fe.jpeg" width="30"></td>
  40. <td><%=next.getBrandName()%></td>
  41. <td><%=next.getCompanyName()%></td>
  42. </tr>
  43. <%
  44. }
  45. %>
  46. </table>
  47. <%
  48. /**
  49. * JSP 四大域 数据的作用域
  50. * page 只限于 当前页面
  51. * request 只限于一次请求
  52. * session 只限于一次会话
  53. * application 整个应用
  54. */
  55. %>
  56. </body>
  57. </html>