在开发web应用程序时,通常需要同时使用3种技术,并分别承担不同的职责。jsp一般来编写用户界面层的信息显示,充当视图层的角色(简称:V);servlet需要来扮演任务的执行者,一般充当控制层的角色(简称:C);Javabean主要实现业务逻辑的处理,充当模型层的角色(简称:M)。这些分工就如同流水线一般,不同的人有不同的任务,承担不同的责任。通过这三种技术的组合实现不同组件功能分工协作,将一个系统的功能分为3种不同类型的组件,这种技术通常称为MVC模式。
目录
五、基于MVC技术+Dao技术的学生信息管理系统的设计(Dao技术是一种数据库连接技术)
一、jsp技术
jsp是一种运行在服务器端的脚本语言,它是用来开发动态网页的技术,是Java web程序开发的重要技术。与jsp相反的就是HTML,它是一种静态网络开发技术。
如果你已经知道了MVC开发模式,想来你应该也已经知道了jsp技术。
如果你不知道的话,那么你可以到菜鸟教程网站或者w3school网站去学习,通过百度就可以查到,这些网站讲的都比较好。
二、Javabean技术
Javaweb是用Java语言编写的、遵循一定标准的类,他封装了数据和业务逻辑,完成数据封装和数据处理等功能。
详情可见:
java web--javabean技术:https://blog.csdn.net/qq_43238335/article/details/105701359
三、servlet技术
Servlet技术是一种Java语言编写的服务器端程序,是由服务器端调用和执行的、按照servlet自身规范编写的Java。servlet可以处理客户端传来的http请求,并返回一个响应。
详情可见:
java web--Servlet技术(一):https://blog.csdn.net/qq_43238335/article/details/105964695
java web--Servlet技术(二):https://blog.csdn.net/qq_43238335/article/details/106138427
四、简单的MVC开发模式介绍
输入圆的半径,求得圆的周长和面积
简单的分为四个部分:两个jsp文件、一个Javabean文件、一个servlet文件。
jsp完成数据的获取和显示,Javabean完成业务逻辑的处理,servlet完成具体的功能。
1.jsp获取数据
<%@ 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>
<p>请输入圆的半径</p>
<hr>
<form action="../a02b" method="post">
<table>
<tr><td>圆的半径:</td><td><input name="radius"></td></tr>
<tr><td><input type="submit" value="确认"></td><td><input type="reset" value="取消"></td></tr>
</table>
</form>
</body>
</html>
2.javabean业务逻辑
package aaa;
public class a02a {
private double radius;
public a02a() {
super();
// TODO Auto-generated constructor stub
}
public a02a(double radius) {
super();
this.radius = radius;
}
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public double mj()
{
return Math.PI*radius*radius;
}
public double zc()
{
return Math.PI*2*radius;
}
}
3.servlet 具体的完成功能,计算出圆的周长和面积
package aaa;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class a02b
*/
@WebServlet("/a02b")
public class a02b extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public a02b() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(request,response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String number=request.getParameter("radius");
double r=Double.parseDouble(number);
a02a aa=new a02a(r);
double mj=aa.mj();
double zc=aa.zc();
request.setAttribute("mj", mj);
request.setAttribute("zc", zc);
request.getRequestDispatcher("/a02/a02d.jsp").forward(request, response);
}
}
4.jsp数据显示
<%@ 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>
<%
out.println("面积为 "+request.getAttribute("mj"));
out.println("<br>");
out.println("周长为 "+request.getAttribute("zc"));
%>
</body>
</html>
五、基于MVC技术+Dao技术的学生信息管理系统的设计(Dao技术是一种数据库连接技术)
我通过Dao技术连接的是MySQL的数据库。
以下是管理系统的流程和结构(仅为查询模块,其余模块与查询模块相同)
1.javabean部分
//User.java文件
package bean1;
public class User {
private int id;
private String name;
private String sex;
private int age;
private double weight;
private double height;
public User() {
super();
// TODO Auto-generated constructor stub
}
public User(int id, String name, String sex, int age, double weight, double height) {
super();
this.id = id;
this.name = name;
this.sex = sex;
this.age = age;
this.weight = weight;
this.height = height;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
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 int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
}
2.Dao部分
//db.properties文件
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/aaa?useUnicode=true&characterEncoding=UTF-8
user=root
password=2411030483
//JdbcUtil.java文件
package bean1;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
public class JdbcUtil {
private static String driver;
private static String url;
private static String user;
private static String password;
private static Properties pr=new Properties();
public JdbcUtil(){
super();
}
static
{
try {
pr.load(JdbcUtil.class.getClassLoader().getResourceAsStream("db.properties"));
driver=pr.getProperty("driver");
url=pr.getProperty("url");
user=pr.getProperty("user");
password=pr.getProperty("password");
try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static Connection getConnection() throws SQLException
{
return DriverManager.getConnection(url,user,password);
}
public static void free(Connection conn,Statement st,ResultSet rs) throws Exception
{
if(conn!=null){conn.close();}
if(st!=null){st.close();}
if(rs!=null){rs.close();}
}
}
//UserDao.java文件
package bean1;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
public class UserDao {
public int add(User user)throws Exception
{
Connection conn=(Connection) JdbcUtil.getConnection();
String sql="insert into biao1(id,name,sex,age,weight,height) values(?,?,?,?,?,?);";
PreparedStatement pstmt=(PreparedStatement) conn.prepareStatement(sql);
pstmt.setInt(1,user.getId());//将第一个占位符赋值
pstmt.setString(2,user.getName());
pstmt.setString(3,user.getSex());
pstmt.setInt(4,user.getAge());
pstmt.setDouble(5,user.getWeight());
pstmt.setDouble(6,user.getHeight());
int n=pstmt.executeUpdate();
JdbcUtil.free(conn,pstmt,null);
return n;
}
public int update(User user)throws Exception
{
Connection conn=(Connection) JdbcUtil.getConnection();
String sql="update biao1 set id=?,name=?,sex=?,age=?,weight=?,height=? where name=? and sex=?";
PreparedStatement pstmt=(PreparedStatement) conn.prepareStatement(sql);
pstmt.setInt(1,user.getId());//将第一个占位符赋值
pstmt.setString(2,user.getName());
pstmt.setString(3,user.getSex());
pstmt.setInt(4,user.getAge());
pstmt.setDouble(5,user.getWeight());
pstmt.setDouble(6,user.getHeight());
pstmt.setString(7,user.getName());
pstmt.setString(8,user.getSex());
int n=pstmt.executeUpdate();
JdbcUtil.free(conn,pstmt,null);
return n;
}
public int delete(String name,String sex,double weight1,double weight2)throws Exception
{
Connection conn=(Connection) JdbcUtil.getConnection();
String sql="delete from biao1 where name=?,sex=?,weight>=? and weight<=?;";
PreparedStatement pstmt=(PreparedStatement) conn.prepareStatement(sql);
pstmt.setString(1,name);
pstmt.setString(2,sex);
pstmt.setDouble(3,weight1);
pstmt.setDouble(4,weight2);
int n=pstmt.executeUpdate();
JdbcUtil.free(conn,pstmt,null);
return n;
}
public List<User> findUserById(double weight1,double weight2)throws Exception
{
Connection conn=(Connection) JdbcUtil.getConnection();
User user=null;
List<User> userList=new ArrayList<User>();
String sql = "select id,name,sex,age,weight,height from biao1 where weight>=? and weight<=?;";//写出对数据库的操作语句,?表示占位符
PreparedStatement pstmt=(PreparedStatement) conn.prepareStatement(sql);
pstmt.setDouble(1,weight1);
pstmt.setDouble(2,weight2);
ResultSet rs=pstmt.executeQuery();
while(rs.next())
{
user=new User();
user.setId(rs.getInt("id"));
user.setName(rs.getString("name"));
user.setSex(rs.getString("sex"));
user.setAge(rs.getInt("age"));
user.setWeight(rs.getDouble("weight"));
user.setHeight(rs.getDouble("height"));
userList.add(user);
}
JdbcUtil.free(conn,pstmt,rs);
return userList;
}
public List<User> QueryAll() throws Exception
{
Connection conn=(Connection) JdbcUtil.getConnection();
User user=null;
List<User> userList=new ArrayList<User>();
String sql="select * from biao1";
PreparedStatement pstmt=(PreparedStatement) conn.prepareStatement(sql);
ResultSet rs=pstmt.executeQuery();
while(rs.next())
{
user=new User();
user.setId(rs.getInt("id"));
user.setName(rs.getString("name"));
user.setSex(rs.getString("sex"));
user.setAge(rs.getInt("age"));
user.setWeight(rs.getDouble("weight"));
user.setHeight(rs.getDouble("height"));
userList.add(user);
}
JdbcUtil.free(conn,pstmt,rs);
return userList;
}
}
3.servlet部分
//a01a_delete2.java文件
package bean1;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class a01a_delete2
*/
@WebServlet("/a01a_delete2")
public class a01a_delete2 extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public a01a_delete2() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
String name=request.getParameter("name");
String sex=request.getParameter("sex");
String ww1=request.getParameter("w1");
String ww2=request.getParameter("w2");
double weight1=Double.parseDouble(ww1);
double weight2=Double.parseDouble(ww2);
UserDao dao=new UserDao();
try {
int n=dao.delete(name, sex, weight1, weight2);
request.setAttribute("number", n);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.getRequestDispatcher("/a01a_delete/a01a_delete3.jsp").forward(request,response);
}
}
//a01a_insert2.jsp文件
package bean1;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class a01a_insert2
*/
@WebServlet("/a01a_insert2")
public class a01a_insert2 extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public a01a_insert2() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
String id=request.getParameter("id_in");
String name=request.getParameter("name_in");
String sex=request.getParameter("sex_in");
String age=request.getParameter("age_in");
String weight=request.getParameter("weight_in");
String height=request.getParameter("height_in");//通过表单获取数据
int id2=Integer.parseInt(id);//将数据转换为相应类型
int age2=Integer.parseInt(age);
double weight2=Double.parseDouble(weight);
double height2=Double.parseDouble(height);
User user=new User(id2,name,sex,age2,weight2,height2);
UserDao dao=new UserDao();
try {
int n=dao.add(user);
request.setAttribute("number", n);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.getRequestDispatcher("/a01a_insert/a01a_insert3.jsp").forward(request,response);
}
}
//a01a_select2.java文件
package bean1;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class a01a_select2
*/
@WebServlet("/a01a_select2")
public class a01a_select2 extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public a01a_select2() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
String weight1 = request.getParameter("weight1");//通过表单获取数据
String weight2 = request.getParameter("weight2");
double wt1 = Double.parseDouble(weight1);
double wt2 = Double.parseDouble(weight2);//将数据转换为相应类型
UserDao dao=new UserDao();
try {
List<User> user=dao.findUserById(wt1, wt2);
request.setAttribute("list", user);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.getRequestDispatcher("/a01a_select/a01a_select3.jsp").forward(request,response);
}
}
//a01a_update.java文件
package bean1;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class a01a_update2
*/
@WebServlet("/a01a_update2")
public class a01a_update2 extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public a01a_update2() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
int id2=Integer.parseInt(request.getParameter("id"));
String name2=request.getParameter("name");
String sex2=request.getParameter("sex");
int age2=Integer.parseInt(request.getParameter("age"));
double weight2=Double.parseDouble(request.getParameter("weight"));
double height2=Double.parseDouble(request.getParameter("height"));
UserDao dao=new UserDao();
User user=new User(id2,name2,sex2,age2,weight2,height2);
try {
int n=dao.update(user);
request.setAttribute("number", n);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.getRequestDispatcher("/a01a_update/a01a_update3.jsp").forward(request,response);
}
}
4.jsp部分
<!-- a01a_delete1.jsp文件 -->
<%@ 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>
<p>请写入删除信息</p>
<hr>
<form action="../a01a_delete2" method="post"><%//创建表单传输数据 %>
姓名: <input type="text" name="name"><br><br>
性别:
男<input type="radio" name="sex" value="男">
女<input type="radio" name="sex" value="女"><br><br>
体重范围:<p>
最低体重: <input type="text" name="w1"><br><br>
最高体重: <input type="text" name="w2"><br><br>
<input type="submit" value="确认">
<input type="reset" value="取消">
</form><br>
</body>
</html>
<!-- a01a_delete3.jsp文件 -->
<%@ 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>
<p>删除界面</p>
<hr>
<%
String a=request.getAttribute("number").toString();
int aa=Integer.parseInt(a);
if(aa>0) out.println("删除成功");
else out.println("删除失败");
%>
</body>
</html>
<!-- a01a_insert1.jsp文件 -->
<%@ 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>
<p>请写入插入信息</p>
<hr>
<form action="../a01a_insert2" method="post"><%//创建表单传输数据 %>
序号: <input type="text" name="id_in"><br><br>
姓名: <input type="text" name="name_in"><br><br>
性别: <input type="text" name="sex_in"><br><br>
年龄: <input type="text" name="age_in"><br><br>
体重: <input type="text" name="weight_in"><br><br>
身高: <input type="text" name="height_in"><br><br>
<input type="submit" value="确认">
<input type="reset" value="取消">
</form><br>
</body>
</html>
<!-- a01a_insert3.jsp文件 -->
<%@ 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>
<p>插入界面</p>
<hr>
<%
String a=request.getAttribute("number").toString();
int aa=Integer.parseInt(a);
if(aa>0) out.println("插入成功");
else out.println("插入失败");
%>
</body>
</html>
<!-- a01a_select1.jsp文件 -->
<%@ 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="../a01a_select2" method="post"><%//创建表单传输数据 %>
<p>请选择想要查询的分数范围</p>
<hr>
最低体重: <input type="text" name="weight1"><br><br>
最高体重: <input type="text" name="weight2"><br><br>
<input type="submit" value="提交">
<input type="reset" value="取消">
</form><br>
</body>
</html>
<!-- a01a_select2.jsp文件 -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.util.List"%>
<%@ page import="bean1.a01a_select2"%>
<%@ page import="bean1.User"%>
<!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>
<p>查询页面</p>
<hr/>
<table>
<tr>
<td>学号</td>
<td>姓名</td>
<td>性别</td>
<td>年龄</td>
<td>体重</td>
<td>身高</td>
</tr>
<%List<User> list2=(List<User>)(request.getAttribute("list"));
for(int i=0;i<list2.size();i++)
{
User u=list2.get(i);
%>
<tr>
<td><%=u.getId()%></td>
<td><%=u.getName()%></td>
<td><%=u.getSex()%></td>
<td><%=u.getAge()%></td>
<td><%=u.getHeight()%></td>
<td><%=u.getHeight()%></td>
</tr>
<%
}
%>
</table>
</body>
</html>
<!-- a01a_update1.jsp文件 -->
<%@ 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>
<p>请写入修改信息</p>
<hr>
<form action="../a01a_update2" method="post">
<table>
<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="age"></td>
</tr>
<tr>
<td>体重</td>
<td><input type="text" name="weight"></td>
</tr>
<tr>
<td>身高</td>
<td><input type="text" name="height"></td>
</tr>
<tr align="center">
<td><input type="submit" value="确认"></td>
<td><input type="reset" value="取消"></td>
</tr>
</table>
</form>
</body>
</html>
<!-- a01a_update2.jsp文件 -->
<%@ 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>
<p>更新界面</p>
<hr>
<%
String a=request.getAttribute("number").toString();
int aa=Integer.parseInt(a);
if(aa>0) out.println("更新成功");
else out.println("更新失败");
%>
</body>
</html>
5.管理页面
<%@ 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>
<frameset rows="80,*">
<frame src="indextitle.jsp" scrolling="no">
<frameset cols="140,*">
<frame src="indexleft.jsp" scrolling="no">
<frame src="indexright.jsp" name="right" scrolling="no">
</frameset>
</frameset>
</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>
<br><br><br><br>
<p><a href="../a01a_insert/a01a_insert1.jsp" target="right">添加学生</a></p>
<p><a href="../a01a_delete/a01a_delete1.jsp" target="right">按条件删除学生</a></p>
<p><a href="../a01a_select/a01a_select1.jsp" target="right">按条件查询学生</a></p>
<p><a href="../a01a_update/a01a_update1.jsp" target="right">按条件修改学生</a></p>
</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>Insert title here</title>
</head>
<body background="1.jpg">
</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>
<center><h1>学生身体体质信息管理系统</h1></center>
</body>
</html>
运行示例如下: