其他分享
首页 > 其他分享> > jsp01

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>

搜索

复制

标签:user1,jsp01,list,add,--%,new,get
来源: https://www.cnblogs.com/wutonga/p/16339965.html