jsp01

<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.bao.user1" %><%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2022/6/1
Time: 21:08
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>登录</title>
</head>
<%--JSP的三种声明--%>
<%--1脚本写java代码 <% %>--%>
<%--2写方法 <%!%>--%>
<%--3写表达式 <%=%>--%>
<body>
<h1>我爱你</h1>
<%
List<user1> list = new ArrayList<>();
list.add(new user1("张三",14));
list.add(new user1("张3",15));
list.add(new user1("张2",16));
%>
<table>
<tr>
<th>姓名</th>
<th>年龄</th>
</tr>
<%
for (int i = 0; i <list.size() ; i++) {
%>
<tr>
<td>
<%=
list.get(i).getName()
%>
</td>
<td>
<%=
list.get(i).getAge()
%>
</td>
</tr>
<%
}
%>
</table>
</body>
</html>
posted @ 2022-06-03 14:41  小松2739  阅读(22)  评论(0编辑  收藏  举报