主页面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生成绩管理系统</title>
</head>
<body>
<h1 align="center">学生成绩管理系统</h1>
<hr size="1" width="100%">
<a href="NewFile11.jsp"><p align="center"><font color="red">学生成绩添加</font></p></a>
<a href="NewFile33.jsp"><p align="center"><font color="red">学生成绩删除</font></p></a>
<a href="NewFile55.jsp"><p align="center"><font color="red">学生成绩查询</font></p></a>
<a href="NewFile77.jsp"><p align="center"><font color="red">学生成绩更新</font></p></a>
</body>
</html>
学生成绩添加页面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生成绩添加</title>
</head>
<body>
<form action="NewFile22.jsp" method="post">
<table border="0" width="238" height="252">
<tr align="center"><th colspan="2">信息添加</th></tr>
<tr><td>学号</td><td><input type="text" name="id"></td></tr>
<tr><td>姓名</td><td><input type="text" name="name"></td></tr>
<tr><td>性别</td><td><input type="text" name="sex"></td></tr>
<tr><td>成绩</td><td><input type="text" name="cj"></td></tr>
<tr align="center">
<td colspan="2">
<input type="submit" value="提 交">
<input type="reset" value="取 消">
</td>
</tr>
</table>
</form>
</body>
</html>
学生成绩添加内容
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,java.io.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String diverName="com.mysql.jdbc.Driver";
String userName="root";
String userPwd="123456";
try{
String dbName="students";
String url1="jdbc:mysql://localhost:3306/"+dbName;
String url2="?user="+userName+"&password="+userPwd;
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(diverName);
Connection conn= DriverManager.getConnection(url);
String sql="insert into stu(id,name,sex,cj) values(?,?,?,?)";
PreparedStatement pstmt=conn.prepareStatement(sql);
request.setCharacterEncoding("UTF-8");
int id=Integer.parseInt(request.getParameter("id"));
String name=request.getParameter("name");
String sex=request.getParameter("sex");
int cj=Integer.parseInt(request.getParameter("cj"));
pstmt.setInt(1, id);
pstmt.setString(2, name);
pstmt.setString(3, sex);
pstmt.setInt(4, cj);
int n=pstmt.executeUpdate();
if(n>0)
{
out.print("添加记录成功,共添加了"+n+"记录!");
}
else
{
out.print("添加记录不成功!");
}
%>
<%
pstmt.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
}
%>
</body>
</html>
学生成绩删除页面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生成绩删除</title>
</head>
<body>
<form action="NewFile44.jsp" method="post">
<table border="0" width="238" height="252">
<tr align="center"><th colspan="2">删除成绩(小到大)</th></tr>
<tr><td>最小值</td><td><input type="text" name="left"></td></tr>
<tr><td>最大值</td><td><input type="text" name="right"></td></tr>
<tr align="center">
<td colspan="2">
<input type="submit" value="提 交">
<input type="reset" value="取 消">
</td>
</tr>
</table>
</form>
</body>
</html>
学生成绩删除内容
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,java.io.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String diverName="com.mysql.jdbc.Driver";
String userName="root";
String userPwd="123456";
try{
String dbName="students";
String url1="jdbc:mysql://localhost:3306/"+dbName;
String url2="?user="+userName+"&password="+userPwd;
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(diverName);
Connection conn= DriverManager.getConnection(url);
String sql2="delete from stu where cj>=? and cj<=?";
PreparedStatement pstmt1=conn.prepareStatement(sql2);
int l=Integer.parseInt(request.getParameter("left"));
int r=Integer.parseInt(request.getParameter("right"));
pstmt1.setInt(1,l);
pstmt1.setInt(2,r);
int n1=pstmt1.executeUpdate();
if(n1>0)
{
out.println("删除记录成功,共删除了"+n1+"记录!");
}
else
{
out.println("删除记录不成功!");
}
%>
<%
pstmt1.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
}
%>
</body>
</html>
学生成绩查询页面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生成绩查询</title>
</head>
<body>
<form action="NewFile66.jsp" method="post">
<table border="0" width="238" height="252">
<tr align="center"><th colspan="2">成绩查询</th></tr>
<tr align="center">
<td colspan="2">
<input type="submit" value="提 交">
<input type="reset" value="取 消">
</td>
</tr>
</table>
</form>
<form action="NewFile66_2.jsp" method="post">
<table border="0" width="238" height="252">
<tr align="center"><th colspan="2">成绩查询(按成绩范围)</th></tr>
<tr><td>最小成绩</td><td><input type="text" name="left"></td></tr>
<tr><td>最大成绩</td><td><input type="text" name="right"></td></tr>
<tr><td>性别</td><td><input type="text" name="sex"></td></tr>
<tr align="center">
<td colspan="2">
<input type="submit" value="提 交">
<input type="reset" value="取 消">
</td>
</tr>
</table>
</form>
</body>
</html>
学生成绩全部查询内容
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,java.io.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String diverName="com.mysql.jdbc.Driver";
String userName="root";
String userPwd="123456";
try{
String dbName="students";
String url1="jdbc:mysql://localhost:3306/"+dbName;
String url2="?user="+userName+"&password="+userPwd;
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(diverName);
Connection conn= DriverManager.getConnection(url);
String sql2="select * from stu";
PreparedStatement pstmt1=conn.prepareStatement(sql2);
ResultSet rs=pstmt1.executeQuery();
rs.last();
%>
你要查询的有
<font size="5" color="red"><%=rs.getRow()%></font>人
<table border="2" width="650">
<tr align="center">
<td>记录条数</td>
<td>学号</td>
<td>姓名</td>
<td>性别</td>
<td>成绩</td>
<tr>
<%rs.beforeFirst();
while(rs.next()){
%>
<tr align="center">
<td><%=rs.getRow()%></td>
<td><%=rs.getString("id")%></td>
<td><%=rs.getString("name")%></td>
<td><%=rs.getString("sex")%></td>
<td><%=rs.getString("cj")%></td>
</tr>
<%} %>
</table>
<%
rs.close();
pstmt1.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
}
%>
</body>
</html>
学生成绩部分查询内容
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,java.io.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String diverName="com.mysql.jdbc.Driver";
String userName="root";
String userPwd="123456";
try{
String dbName="students";
String url1="jdbc:mysql://localhost:3306/"+dbName;
String url2="?user="+userName+"&password="+userPwd;
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(diverName);
Connection conn= DriverManager.getConnection(url);
String sql2="select * from stu where cj>=? and cj<=? and sex=?";
PreparedStatement pstmt1=conn.prepareStatement(sql2);
request.setCharacterEncoding("UTF-8");
int l=Integer.parseInt(request.getParameter("left"));
int r=Integer.parseInt(request.getParameter("right"));
String s=request.getParameter("sex");
pstmt1.setInt(1, l);
pstmt1.setInt(2, r);
pstmt1.setString(3, s);
ResultSet rs=pstmt1.executeQuery();
rs.last();
%>
你要查询的有
<font size="5" color="red"><%=rs.getRow()%></font>人
<table border="2" width="650">
<tr align="center">
<td>记录条数</td>
<td>学号</td>
<td>姓名</td>
<td>性别</td>
<td>成绩</td>
<tr>
<%rs.beforeFirst();
while(rs.next()){
%>
<tr align="center">
<td><%=rs.getRow()%></td>
<td><%=rs.getString("id")%></td>
<td><%=rs.getString("name")%></td>
<td><%=rs.getString("sex")%></td>
<td><%=rs.getString("cj")%></td>
</tr>
<%} %>
</table>
<%
rs.close();
pstmt1.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
}
%>
</body>
</html>
学生成绩更新页面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生成绩更新</title>
</head>
<body>
<form action="NewFile88.jsp" method="post">
<table border="0" width="238" height="252">
<tr align="center"><th colspan="5">更新成绩</th></tr>
<tr><td colspan="4">姓名</td><td><input type="text" name="name"></td></tr>
<tr><td colspan="4">成绩修改为</td><td><input type="text" name="cj"></td></tr>
<tr align="center">
<td colspan="5">
<input type="submit" value="提 交">
<input type="reset" value="取 消">
</td>
</tr>
</table>
</form>
</body>
</html>
学生成绩更新内容
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,java.io.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String diverName="com.mysql.jdbc.Driver";
String userName="root";
String userPwd="123456";
try{
String dbName="students";
String url1="jdbc:mysql://localhost:3306/"+dbName;
String url2="?user="+userName+"&password="+userPwd;
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(diverName);
Connection conn= DriverManager.getConnection(url);
String sql="update stu set cj=? where name=?";
PreparedStatement pstmt=conn.prepareStatement(sql);
request.setCharacterEncoding("UTF-8");
int c=Integer.parseInt(request.getParameter("cj"));
String nn=request.getParameter("name");
pstmt.setInt(1, c);
pstmt.setString(2, nn);
int n=pstmt.executeUpdate();
if(n>0)
{
out.print("更新记录成功,共更新了"+n+"记录!");
}
else
{
out.print("更新记录不成功!");
}
%>
<%
pstmt.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
}
%>
</body>
</html>