表格形式在页面显示信息

40 篇文章 0 订阅
26 篇文章 0 订阅

Student.java

package text.bean;

public class Student {
	private String name;
	private int age;
	private int height;
	
	
	public Student() {
		super();
	}
	public Student(String name, int age, int height) {
		super();
		this.name = name;
		this.age = age;
		this.height = height;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public int getHeight() {
		return height;
	}
	public void setHeight(int height) {
		this.height = height;
	}
	

}

jstl.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.util.*,com.ujiuye.bean.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		Student stu1 = new Student("张三",20,175);
		Student stu2 = new Student("李四",30,160);
		Student stu3 = new Student("王五",40,170);
		Student stu4 = new Student("姚明",40,225);
		Student stu5 = new Student("长江",60,155);
		Student stu6 = new Student("赵六",10,175);
		List<Student> list = new ArrayList();
		list.add(stu1);
		list.add(stu2);
		list.add(stu3);
		list.add(stu4);
		list.add(stu5);
		list.add(stu6);
		//放入到作用域中
		request.setAttribute("list", list);
	%>
	<table border="1">
	 <tr>
	 	<th>姓名</th>
	 	<th>年龄</th>
	 	<th>身高</th>
	 </tr>
	<c:forEach items="${list}" var="stu" varStatus="xx">
		<tr>
			<td>${stu.name}</td>
			<td>${stu.age}</td>
			<td>${stu.height}</td>
		</tr>
	</c:forEach>
	</table>
</body>
</html>

在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值