<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<%@page import="com.star.mode.Person"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
</head>

<body>
<%
List<Person> list1 = new ArrayList<Person>();
Person p1 = new Person();
p1.setAge(10);
p1.setName("张三");

Person p2 = new Person();
p2.setAge(20);
p2.setName("李四");

Person p3 = new Person();
p3.setAge(30);
p3.setName("王五");

list1.add(p1);
list1.add(p2);
list1.add(p3);

request.setAttribute("all", list1);
%>
<br>
<h1>
${all[0]}
</h1>
<c:if test="${all != null}">
<c:forEach var="person" items="${all}">
${person.age}<br/>
${person.name}<br/>
</c:forEach>
</c:if>
</body>
</html>
评论
发表评论

您还没有登录,请登录后发表评论

star022
搜索本博客
最近加入圈子
最新评论
评论排行榜