1.在JSP的页面中以表格的形式打印九九乘法表:
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%
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>
<title>My JSP 'first.jsp' starting page</title>
</head>
<body>
<!-- 在JSP的页面中以表格的形式打印九九乘法表 -->
<h1>九九乘法表</h1>
<%
for(int i=1;i<=9;i++)
{
for(int j=1;j<=i;j++)
{
out.println(i+"*"+j+"="+(i*j)+" ");
}
out.println("<br/>");
}
%>
</body>
</html>
2、用表格的形式将数据库中一张表的所有内容(包含列名和记录信息)输出到页面上:
①学生
Stu
package com.bright.bean;
public class Stu {
private String num;
private String name;
private String sex;
private String banji;
private String nianji;
public Stu() {
super();
// TODO Auto-generated constructor stub
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getBanji() {
return banji;
}
public void setBanji(String banji) {
this.banji = banji;
}
public String getNianji() {
return nianji;
}
public void setNianji(String nianji) {
this.nianji = nianji;
}
}
②StuDao
package com.bright.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import c