<%@ page import="java.util.List" %> <%@ page import="java.util.ArrayList" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <% List list=new ArrayList<>(); List l1 = new ArrayList<>(); l1.add(1); l1.add("111"); l1.add(2); List l2 = new ArrayList<>(); l2.add(2); l2.add("222"); l2.add(2); list.add(l1); list.add(l2); request.setAttribute("list",list); %> <table> <tr> <td>图书编号</td> <td>书名</td> <td>价格</td> <td>作者</td> <td>简介</td> </tr> <c:forEach var="book" items="${list}"> <tr> <td>${book[0]}</td> <td>${book[1]}</td> <td>${book[2]}</td> </tr> </c:forEach> </table> </body> </html>
jsp c foreach 二维数组
最新推荐文章于 2022-06-01 11:28:10 发布