想要在JSP中以表格形式显示数据

时间:2016-07-29 17:22:19

标签: jsp servlets jsp-tags

我想在jsp页面的每一行中只显示3条记录。 记录字段只有一个(例如产品名称)。因此每行只显示T3产品名称。 如何在JSP中执行?

1 | 2 | 3

4 | 5 | 6

7 | 8 | 9

请帮助!!!

1 个答案:

答案 0 :(得分:0)

你在找这个吗?

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Table Example</title>
</head>
  <body>

      <div align="center">
          <table border="1" cellpadding="5">
              <tr>
                  <th>Column 1</th>
                  <th>Column 2</th>
                  <th>Column 3</th>
              </tr>
              <c:forEach var="data" items="${your list here}">
                  <tr>
                      <td><c:out value="${value here}" /></td>
                      <td><c:out value="${value here}" /></td>
                      <td><c:out value="${value here}" /></td>
                  </tr>
              </c:forEach>
          </table>
      </div>
  </body>
</html>
相关问题