使用Tomcat作为Web服务器和Servlet容器,使用SQL Server/MySQL作为数据服务器,从浏览器端发起对Servlet的调用,完成如下任务:
(1)向scores表中插入新的记录,表示录入新学生信息;(注意:学号为主键,插入学号相同的学生要提示错误;如果学号由数据库自动生成除外)
(2)批量录入成绩,即:在一个界面上列出所有学生信息,在同一个界面上成绩还可以重新录入;录入部分或者全部学生成绩后,提交,将所有成绩写入scores表。(没有录入的成绩,可以暂定为0写入scores表)
使用的静态html页面和动态Servlet的个数没有限制。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<table>
<tr>
<td><a href="searchall">查询全部+修改成绩</a></td>
</tr>
</table>
<table>
<tr>
<td><a href="InsertAndSearch">查询全部+批量录入(包括成绩)</a></td>
</tr>
</table>
<table>
<tr>
<td><a href="InsertAndSearchTwo">查询全部+批量录入(不包括成绩)</a></td>
</tr>
</table>
<table>
<tr>
<td><a href="deleteall">全部删除</a></td>
</tr>
</table>
<table>
<tr>
<td><a href="quanb">shishi</a></td>
</tr>
</table>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@page import="java.util.List"%>
<%@page import="TheStudent.Student"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<body>
<table align="center" width="400" border="1">
<tr>
<td align="center" colspan="5">
<h2>所有学生信息</h2>
</td>
</tr>
<tr align="center">
<td><b>学号</b></td>
<td><b>姓名</b></td>
<td><b>性别</b></td>
<td><b>成绩</b></td>
<td><b>修改成绩</b></td>
</tr>
<%
// 获取图书信息集合
List<Student> list=(List<Student>)request.getAttribute("list");
if(list==null || list.size()<1){
out.print("没有 数据!");
}
else{
for(Student student:list){
%>
<tr align="center">
<td><%=student.getId() %></td>
<td><%=student.getName() %></td>
<td><%=student.getSex() %></td>
<td><%=student.getGrade() %></td>
<td>
<form action="Alter" method="post" οnsubmit="return check(this);">
<input name="id" id="id" type="hidden" value=<%=student.getId() %>>
<input name="grade" id="grade" type="text" size="5"/>
<input type="submit" value="修 改">
</form>
</td>
</tr>
<%
}
}
%>
</table>
<a href="Start.html">返回上一目录</a>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@page import="java.util.List"%>
<%@page import="TheStudent.Student"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<table align="center" width="500" border="1">
<form action="InsertTwo" method="post" οnsubmit="return check(this);">
<tr>
<td align="center" colspan=7">
<h2><b>录入信息</b></h2>
</td>
</tr>
<tr align="center">
<td><b>学号</b></td>
<td><input name="id" id="id" type="text" size="4"/></td>
<td><b>姓名</b></td>
<td><input name="name" id="name" type="text" size="6"/> </td>
<td><b>性别</b></td>
<td><input name="sex" id="sex" type="text" size="4"/></td>
<td><input name="Submit" type="submit" value="添加" οnclick=getParameter></td>
</tr>
</table>
<table align="center" width="500" border="1">
<tr>
<td align="center" colspan="4">
<h2>所有学生信息</h2>
</td>
</tr>
<tr align="center">
<td><b>学号</b></td>
<td><b>姓名</b></td>
<td><b>性别</b><<