java jsp的动态添加行

<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8" import="enetity.Student"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
	<%
		Student s1 = new Student("张三",15);
		Student s2 = new Student("李四",16);
		Student s3 = new Student("王五",17);
		Student s4 = new Student("赵六",18);
		Student s5 = new Student("田七",19);
		List<Student> list = new ArrayList();
		list.add(s1);
		list.add(s2);
		list.add(s3);
		list.add(s4);
		list.add(s5);
		request.setAttribute("stu", list);		
	%>
	<table border="1">
		<tr>
			<th>下标</th>
			<th>序号</th>
			<th>是否为第一个</th>
			<th>是否为最后一个</th>
			<th>年龄</th>
			<th>姓名</th>
		</tr>
		<%-- 你要遍历的结果集,遍历出的每一个对象都交给var --%>
		<c:forEach items="${stu}" var="st" varStatus="s" >
			<tr>
				<%-- varStatus对象把一些常用信息存入到他的属性中 --%>
				<td>${s.index}</td>
				<td>${s.count}</td>
				<td>${s.first}</td>
				<td>${s.last}</td>
				<td>${st.age}</td>
				<td>${st.username}</td>
			</tr>
		</c:forEach>
	</table>
</body>
</html>
上一篇:java – 绘制其他不适用于Android 8.0的应用程序


下一篇:Centos7 修改docker文件系统引擎为overlayfs