201711671104-信管1171-陈张建-智多星手机销售管理系统

本文档详述了一款基于Java的智多星手机销售管理系统的实现,包括前端用户界面和后台管理功能。系统实现了登录、注册、手机信息的增删改查以及订单管理等功能。前端代码来源于老师,后端由作者改编自学生信息管理系统。文章提供了百度云链接以获取源码,并展示了数据库表结构。虽然面临时间紧迫和前端代码理解的挑战,但作者计划在未来完善系统,尤其是前端部分,并推荐学习Bootstrap响应式布局设计。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

总设计源码百度云链接:

链接:https://pan.baidu.com/s/1XTl_v5N9b12KJ5U6P2f31Q 
提取码:1ar3 

一、前端(老师给的前端代码的运行截图)

老师给的代码复制进去(不可以通过import file导入老师给的代码,必须要一个页面一个页面地复制,否则tomcat服务器发布了项目也不能同步到tomcat的webapps文件夹里),只需要把每个页面连接数据库的语句(比如用户名和密码等)修改一下以及相关jar包的导入即可正常运行,用户登陆的信息是保存在JavaBean对象里的,每个操作如果检测到没有用户登陆就会优先让你先登陆账号才能进行下一步的操作。

智多星销售网主页:

登陆界面:

注册页面:

注册成功页面:

浏览手机功能页面:

查询手机信息功能页面:

查看购物车页面(需要先登陆):

查看订单页面(需要先登陆):

二、后台管理系统

后台管理页面是由我之前编写的学生信息管理系统改编而来,后台的数据存储在servlet里面,进入后台管理系统后必须要先登陆管理员账号密码,而管理员账号密码存储在数据库表login(自己创建的一个数据库表,里面只要logname、realname和password三个变量)里,而登陆后的logname会存储在servlet里,如果当前页面检测到servlet里没有logname的信息,系统就会自动弹出“请先登陆”提示框,这是为了防止用户直接运行其他jsp页面而导致的系统功能不完整。由于想象不到后台还有哪些功能且课设时间有限,我就简单地做了手机信息和订单信息的增删改查以及管理员密码的修改等操作,后续操作需要实现的话可以继续添加进去,所以这个后台管理系统还有有待改进。

进入后台管理功能页面(需要先登陆管理员账号):

后台管理系统主页:

添加手机信息页面:

手机信息管理页面(模拟树形菜单实现简单功能)

手机信息更新操作:

手机信息删除操作:

订单信息管理页面:

订单信息的添加操作:

 

 

订单信息的修改操作:

 

手机信息简介页面:

订单信息的删除操作:

修改管理员密码页面:

三、代码截图:

前端的代码就是老师给的那些就不一一展示出来了,这里我就把我后台的代码贴出来以供大家参考,如有错误,请多指教。

1、所有代码截图:

2、head.txt的代码,这是本销售系统的主页,由9个超链接组成,比老师给的代码多了一个后台管理链接。

<%@ page contentType="text/html;charset=GB2312" %>
<div align="center">
  <H2>“智多星”智能手机销售网</H2>
  <table  cellSpacing="1" cellPadding="1" width="660" align="center"    border="0" >
   <tr valign="bottom">
   <td><A href="inputRegisterMess.jsp"><font size=2>注册</font></A></td>
   <td><A href="login.jsp"><font size=2>登录</font></A></td>
   <td><A href="lookMobile.jsp"><font size=2>浏览手机</font></A></td>
   <td><A href="searchMobile.jsp"><font size=2>查询手机</font></A></td>
   <td><A href="lookShoppingCar.jsp"><font size=2>查看购物车</font></A></td>
   <td><A href="lookOrderForm.jsp"><font size=2>查看订单</font></A></td>
   <td><A href="exitServlet"><font size=2>退出</font></A></td>
   <td><A href="index.jsp"><font size=2>主页</font></A></td>
   <td><A href="MyJsp.jsp"><font size=2>后台管理</font></A></td>
  </tr>
  </Font>
</table>
</div>

3、Login.html代码这个是主登陆界面,用户必须输入存储在数据库login表里的记录才能成功登陆,登陆成功后系统会把登陆成功的用户的logname存储在servlet里。

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>请登陆</title>
		<link href="Resources/css/Login.css" type="text/css" rel="stylesheet" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
  		<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">
  		<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  		<script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
  		<script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script> <!--链接样式表-->
		<script language="JavaScript">
			function checkForm(form){
				for(var i = 0;i<form.elements.length;i++){
					if((form.elements[i].type == "text"||form.elements[i].type == "password" )&& form.elements[i].value == ""){
						alert("请输入用户名或密码!");//用户名或者密码输入为空时,弹出提示语请输入用户名或密码
						return false;
					}
				}
				return true;
			}
			function exit(){   //点击退出按钮后询问是否真的要退出整个程序
			var res = confirm("是否要退出程序?");
                  if(res == true){
 					window.close();
 }
 					else {
 					window.location.href="Login.html";
 					}
}
	</script>
	<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>
	<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-18" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/Login.html">
		<div id="bg" data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-18" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/Login.html">
1			<div id="whiteblock">	
				<h2>后台管理系统登录</h2>
				<form action="DAOCheckLogin.jsp" method="post" onsubmit="return checkForm(this)">
					<div class="input-group input-group-lg">
						<p><input type="text" name="logname" class="form-control user" placeholder="请输入管理员用户名" size="25"></p>
						<p><input type="password" name="password" class="form-control user" placeholder="请输入管理员密码" size="25"></p>
					</div>
					<p>
						<input type="submit" id="put" value="登录" class="btn btn-primary" /> 
						<input type="reset" id="put" value="重置" class="btn btn-warning" />
						<input type="button" id="put" value="退出" class="btn btn-danger" onclick="exit()"/>  
						<!--使用Bootstrap按钮来设置样式-->
					</p>
				</form>
			</div>
		</div>
	</body>
</html>

4、DAOCheckLogin.jsp的代码,这是检查你所输入的登陆信息,连接数据库,查看数据库里的login表里是否有你所输入的这个记录,如果没有该记录则登陆失败跳转至login.html页面;如果存在该记录则登陆成功跳转到frame.jsp后台管理系统主页面并将已登陆用户的logname和realname存储到servlet里。

<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ 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>
<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>
<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-7" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/DAOCheckLogin.jsp">
<%
	//检验管理员的用户名密码是否正确
	request.setCharacterEncoding("UTF-8");
	String logname = request.getParameter("logname");
	String password = request.getParameter("password");
	String sqlQuery = "SELECT * FROM mobileshop.login WHERE logname='"+logname+"'AND password='"+password+"'";
	try{
		Class.forName("com.mysql.cj.jdbc.Driver");
		String URL = "jdbc:mysql://127.0.0.1:3306/mobileshop?useSSL=false&user=root&password=123456&serverTimezone=GMT%2B8";
		System.out.println("连接成功...");
		Connection con = DriverManager.getConnection(URL);
		Statement sql = con.createStatement();
		ResultSet rs = sql.executeQuery(sqlQuery);
		if(rs.next()){
			session.setAttribute("logname", logname);
			session.setAttribute("realname", rs.getString(3));
			response.sendRedirect("frame.jsp");//登陆成功,重定向至菜单管理页面
		}else{
			out.print("<script language='JavaScript'>alert('您的用户名或密码有误,请重新输入或者注册');window.location.href='Login.html'</script>");
			//登陆失败,跳转到登陆页面
		}
		con.close();
	}catch(SQLException e){
		e.printStackTrace();
	}
%>
</body>
</html>

 5、Top.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>
<style type="text/css">
	.block{
		width: 1300px;
		height: 50px;
		background-color: #ccc;
		border-radius: 10px;
		margin: 0 auto;
	}
	h3{
		text-align: center;
		padding-top: 12px;
		font-family: "微软雅黑";
	}
</style>
<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>
<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-22" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/Top.jsp">
	<div class="block" data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-22" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/Top.jsp">
		<%
			if((String)session.getAttribute("logname")==null){
				out.print("<script language='JavaScript'>alert('请先登录!');window.location.href='Login.html'</script>");
				//如果检查到没有用户登陆,则重定向至主登陆页面
			}
		%>
		<h3>您好!<%=(String)session.getAttribute("realname") %>管理员,欢迎来到后台管理系统</h3>
	</div>
</body>
</html>

 6、Left_nav.html页面的代码,这是后台管理系统主页面的左边部分,用于实现左右树形菜单与实现功能的划分。

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
		<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
		<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
		<style type="text/css">
			ul{
				width: 150px;
				height: 200px;
				float: right;
				margin-top: 100px;
				
			}
		</style>
	<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>
	<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-17" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/Left_nav.html">
	<ul class="nav nav-tabs" data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-17" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/Left_nav.html">
    <li class="dropdown">
        <a class="dropdown-toggle" data-toggle="dropdown" href="#">后台管理
            <span class="caret"></span></a>
        <ul class="dropdown-menu">
           <li><a href="Contain.jsp?pages=1" target="contain">手机信息管理</a></li>
			<li><a href="Contain2.jsp?pages=1" target="contain">订单信息管理</a></li>
			<li><a href="AdminPasswordReset.jsp" target="contain">账号密码重置</a></li>
        </ul>
    </li>
     <li>
        <a href="SystemExit.jsp" target="_parent">退出系统</a></li>
</ul>

	</body>
</html>

7、Contain.jsp页面的代码,这是功能实现的初始页面,是一个管理手机信息的页面,你可以通过点击左边树形菜单的选项来改变该显示区域的内容,动静结合。

<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ 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">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<!-- Bootstrap CSS -->
		<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
		<!-- Optional JavaScript -->
		<!-- jQuery first, then Popper.js, then Bootstrap JS -->
		<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
		<script type="text/javascript">
			function del() {
				if(!confirm("确认要删除?")) {
					window.event.returnValue = false;
				}
			}
		</script>
		<title>手机网后台管理系统</title>
		<style type="text/css">
			body {
				/*background-color: #eee;*/
			}
			
			form h1 {
				display: inline-block;
				width: 820px;
			}
			
			.check {
				padding: 30px 30px;
			}
			
			form {
				display: inline;
			}
			
			.contain {
				width: 1000px;
				border-radius: 10px;
				border: 1px #bbb solid;
				background-color: #eee;
				padding-top: 20px;
			}
			
			button {
				margin-left: 10px;
			}
			
			.search {
				display: inline-block;
				margin-left: 500px;
			}
			
			.add {
				float: right;
				margin-right: 50px;
			}
			.pageNav{
				margin-left: 200px;
			}
		</style>
	<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>

	<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-5" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/Contain.jsp">
		<%
		request.setCharacterEncoding("UTF-8");
		String pages = request.getParameter("pages");//获取当前页数
		int pagesNo = Integer.parseInt(pages);//把当前页数从字符串转为整型
		int startLine = (Integer.parseInt(pages)-1)*10;//指定数据库从哪一行开始读取
		%>
		<div class="contain pull-left" data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-5" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/Contain.jsp">
			<form action="DaoSearch.jsp" class="form-inline ">
				<h2>手机信息管理</h2>
				<div class="form-group search">
					<input type="text" name="check" class="form-control" placeholder="请输入查询手机名称或手机标识号" />
					<input type="submit" name="submit" value="搜索" />

				</div>
			</form>
			<a href="Phone.jsp" target="_self"><button >手机信息简介</button></a>
			<a href="AddStudent.jsp" target="_self"><button>添加手机信息</button></a>
			<div class="pull-left">
				<table class="table table-hover">
					<thead>
						<tr>
							<th>手机标识号</th>
							<th>手机名称</th>
							<th>手机厂商</th>
							<th>手机价格</th>
							<th>手机简介</th>
							<th>手机模型图</th>
							<th>手机类别号</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
<%
	int pageSize = 10;//指定数据库一次读取多少行
	String sqlQuery = "SELECT * FROM mobileshop.mobileForm limit "+startLine+","+pageSize;//对数据库进行伪分页读取,一次只能读10行
	String sqlAll = "SELECT * FROM mobileshop.mobileForm";
	int pagesCount = 0;//用于数据库最后读出所有行后总共有多少页
	int lastRow = 0;//记录数据库的最后一行
	try{
		Class.forName("com.mysql.cj.jdbc.Driver");
		String URL = "jdbc:mysql://127.0.0.1:3306/mobileshop?useSSL=false&user=root&password=123456&serverTimezone=GMT%2B8";
		Connection con = DriverManager.getConnection(URL);
		Statement sql = con.createStatement();
		Statement stat = con.createStatement();
		ResultSet rs = sql.executeQuery(sqlQuery);
		ResultSet rsAll = stat.executeQuery(sqlAll);
		rsAll.last();
		lastRow = rsAll.getRow();//记录数据库最后一行
		while(rs.next()){
			out.print("<tr>");
			out.print("<td>"+rs.getString(1)+"</td>");
			out.print("<td>"+rs.getString(2)+"</td>");
			out.print("<td>"+rs.getString(3)+"</td>");
			out.print("<td>"+rs.getString(4)+"</td>");
			out.print("<td>"+rs.getString(5)+"</td>");
			out.print("<td>"+rs.getString(6)+"</td>");
			out.print("<td>"+rs.getString(7)+"</td>");
			out.print("<td><a href='AlertStudent.jsp?mobile_version="+rs.getString(1)+"'><button>修改</button></a><a href='DaoDelete.jsp?mobile_version="+rs.getString(1)+"' onclick='javascript:return del();'><button>删除</button></a></td>");
			out.print("</tr>");
		}
		con.close();
	}catch(SQLException e){
		e.printStackTrace();
	}
%>

					</tbody>
				</table>
				<div class="pageNav">
					<ul class="pagination">
					<%
						int prePage;//上一页的页数
						if(pagesNo == 1){
							prePage = 1;//若当前页是第一页,则第一页只能是当前页
						}else{
							prePage = pagesNo - 1;//除了上述情况外上一页等于当前页-1页
						}
					%>
					<li class="page-item"><a class="page-link" href="Contain.jsp?pages=<%=prePage%>">上一页</a></li>
					<%
						pagesCount = (lastRow % pageSize == 0) ? (lastRow / pageSize) : (lastRow / pageSize +1);//计算数据库能读出来的全部页数
						int minpages = (pagesNo - 3 >0) ? (pagesNo - 3) : 1;//设定最小页,防止页数小于第一页
						int maxpages = (pagesNo + 3 >= pagesCount) ? (pagesCount) : (pagesNo+3);//设定最大页
						for(int i = minpages;i <=maxpages ;i++){
							if(i == pagesNo){//当前页和遍历出来的页数相等时,需要通过调用css里面的样式“active"进行高亮
								out.print("<li class='page-item active'>");
								out.print("<a class='page-link' href='Contain.jsp?pages="+i+"'>"+i+"</a>");
								out.print("</li>");
							}else{//输出每一个分页
								out.print("<li class='page-item'>");
								out.print("<a class='page-link' href='Contain.jsp?pages="+i+"'>"+i+"</a>");
								out.print("</li>");
							}
							
						}
							//out.print("<li class='page-item'>");
							//out.print("<a class='page-link' href='#>...</a>");
							//out.print("</li>");
						
					%>
					<%
						int nextPage;
						if(pagesNo == pagesCount){//下一页的原理和上一页同理
							nextPage = pagesCount;
						}else{
							nextPage = pagesNo + 1;
						}
					%>
					<li class="page-item"><a class="page-link" href="Contain.jsp?pages=<%=nextPage%>">下一页</a></li>
					</ul>
				</div>

			</div>

		</div>
	</body>

</html>

8、frame.jsp页面的代码,这是将上面5、6、7三个页面(Top.jsp,Left.html,Contain.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 data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-23" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/frame.jsp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>
<%
if((String)session.getAttribute("logname")==null){
	out.print("<script language='JavaScript'>alert('请先登录!');window.location.href='Login.html'</script>");
}
%>
<frameset rows="10%,*" frameborder="0" framespacing="10">
		<frame src="Top.jsp" noresize="noresize" scrolling="yes" />
		<frameset cols="30%,*">
			<frame src="Left_nav.html" noresize="noresize" />
			<frame src="Contain.jsp?pages=1" name="contain" />
		</frameset>
	</frameset>
</html>

9、AddStudent.jsp页面的代码,这是通过点击Contain.jsp跳转到本页面,是用于实现添加手机信息操作的页面,这里是需要你在输入框中输入你所要添加的手机信息再通过表单提交到DaoAddStudent.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">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<!-- Bootstrap CSS -->
		<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
		<!-- Optional JavaScript -->
		<!-- jQuery first, then Popper.js, then Bootstrap JS -->
		<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
		<title>Insert title here</title>
		<style type="text/css">
			.form-control {
				width: 300px;
				height: 30px;
				float: right;
			}
			
			select {
				width: 210px;
				height: 30px;
			}
			
			.submit {
				margin-left: 100px;
				margin-right: 30px;
			}
			
			.contain {
				width: 1000px;
				border: 1px #bbb solid;
				background-color: #eee;
				padding-top: 20px;
				border-radius: 10px;
			}
			
			label {
				display: inline-block;
				width: 100px;
				margin-right: 10px;
			}
			
			form {
				margin-left: 300px;
			}
		</style>
	<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>

	<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-0" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/AddStudent.jsp">
	<%
		if((String)session.getAttribute("logname")==null){
			out.print("<script language='JavaScript'>alert('请先登录!');window.location.href='Login.html'</script>");
		}//提示登陆,并且在当前页面打开Login.html页面
	%>
		<div class="contain" data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-0" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/AddStudent.jsp">
			<form action="DaoAddStudent.jsp" method="post">
				<div class="form-group form-inline">
					<label for="mobile_version">标识号:</label>
				<input type="text" class="form-control" id="mobile_version" name="mobile_version" maxlength="15" required="required" placeholder="请输入你的手机标识号:">
				</div>
			<div class="form-group form-inline">
				<label for="mobile_name">手机名称:</label>
					<input type="text" class="form-control" id="mobile_name" name="mobile_name" required="required">
				</div>
				<div class="form-group form-inline">
					<label for="mMobile_made">手机厂商:</label>
					<input type="text" class="form-control" id="nmMobile_madeame" name="mMobile_made" required="required">
				</div>
				<div class="form-group form-inline">
					<label for="mobile_price">手机价格:</label>
					<input type="text" class="form-control" id="mobile_price" name="mobile_price" required="required">
				</div>
				<div class="form-group form-inline">
					<label for="mobile_mess">手机简介:</label>
					<input type="text" class="form-control" id="mobile_mess" name="mobile_mess" required="required">
				</div>
				<div class="form-group form-inline">
					<label for="mobile_pic">手机模型图:</label>
					<input type="text" class="form-control" id="mobile_pic" name="mobile_pic" required="required">
				</div>
				<div class="form-group form-inline">
					<label for="id">手机类别号:</label>
					<input type="text" class="form-control" id="id" name="id" required="required">
				</div>
				<div class="form-group form-inline">
					<input type="submit" id="" name="" class="btn btn-primary submit" value="添加"><input type="reset" class="btn btn-warning" value="重置" />
				</div>
			</form>
		</div>
	</body>
</html>

10、DaoAddStudent.jsp页面的代码,这是从AddStudent.jsp跳转到本页面,是通过连接数据库实现添加手机信息操作的页面。

11、AlertStudent.jsp页面的代码,这是输入需要更新的手机信息的页面,与AddStudent.jsp类似。

<%@page import="org.omg.CORBA.Request"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ 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">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<!-- Bootstrap CSS -->
		<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
		<!-- Optional JavaScript -->
		<!-- jQuery first, then Popper.js, then Bootstrap JS -->
		<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
		<title>Insert title here</title>
		<style type="text/css">
			.form-control {
				width: 300px;
				height: 30px;
				float: right;
			}
			
			select {
				width: 210px;
				height: 30px;
			}
			
			.submit {
				margin-left: 100px;
				margin-right: 30px;
			}
			
			.contain {
				width: 1000px;
				border: 1px #bbb solid;
				background-color: #eee;
				padding-top: 20px;
				border-radius: 10px;
			}
			
			label {
				display: inline-block;
				width: 100px;
				margin-right: 10px;
			}
			
			form {
				margin-left: 300px;
			}
		</style>
	<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>

	<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-3" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/AlertStudent.jsp">
	<%!
	String sourceId;
	String mobile_version;
	String mobile_name;
	String mMobile_made;
	String mobile_price;
	String mobile_mess;
	String mobile_pic;
	String id;
	%>
	<%
	
		if((String)session.getAttribute("logname")==null){
			out.print("<script language='JavaScript'>alert('请先登录!');window.location.href='Login.html'</script>");
		}
	
		request.setCharacterEncoding("UTF-8");
		mobile_version= request.getParameter("mobile_version");
		String sqlid = "SELECT * FROM mobileshop.mobileForm where mobile_version='"+mobile_version+"'";
		sourceId = mobile_version;
		try{
			Class.forName("com.mysql.cj.jdbc.Driver");
			String URL = "jdbc:mysql://127.0.0.1:3306/mobileshop?useSSL=false&user=root&password=123456&serverTimezone=GMT%2B8";
			Connection con = DriverManager.getConnection(URL);
			Statement sql = con.createStatement();
			ResultSet rs = sql.executeQuery(sqlid);
			if(rs.next()){
				mobile_version=rs.getString(1);
				mobile_name = rs.getString(2);
				mMobile_made= rs.getString(3);
				mobile_price = rs.getString(4);
				mobile_mess = rs.getString(5);
				mobile_pic= rs.getString(6);
				id = rs.getString(7);
			}
			rs.close();
			sql.close();
			con.close();
		}catch(Exception e){
			e.printStackTrace();
		}
		
	%>
		<div class="contain" data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-3" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/AlertStudent.jsp">
			<form action="DaoAlertStudent.jsp?sourceId='<%=sourceId %>'" method="post">
				<div class="form-group form-inline">
					<label for="mobile_version">标识号:</label>
				<input type="text" class="form-control" id="mobile_version" name="mobile_version" value='<%=mobile_version %>' required="required">
				</div>
			<div class="form-group form-inline">
				<label for="mobile_name">手机名称:</label>
					<input type="text" class="form-control" id="mobile_name" name="mobile_name" maxlength="15" value='<%=mobile_name %>' required="required">
				</div>
				<div class="form-group form-inline">
				<label for="mMobile_made">手机厂商:</label>
					<input type="text" class="form-control" id="mMobile_made" name="mMobile_made" maxlength="15" value='<%=mMobile_made %>' required="required">
				</div>
				<div class="form-group form-inline">
					<label for="mobile_price">手机价格:</label>
					<input type="text" class="form-control" id="mobile_price" name="mobile_price" value='<%=mobile_price %>' required="required">
				</div>
				<div class="form-group form-inline">
					<label for="mobile_mess">手机简介:</label>
					<input type="text" class="form-control" id="mobile_mess" name="mobile_mess" value='<%=mobile_mess%>' required="required">
				</div>
				<div class="form-group form-inline">
					<label for="mobile_pic">手机模型图:</label>
					<input type="text" class="form-control" id="mobile_pic" name="mobile_pic" value='<%=mobile_pic %>' required="required">
				</div>
				<div class="form-group form-inline">
					<label for="id">手机分类号:</label>
					<input type="text" class="form-control" id="id" name="id" value='<%=id %>' required="required">
				</div>
				<div class="form-group form-inline">
					<input type="submit" id="" name="" class="btn btn-primary submit" value='修改' /><input type="reset" class="btn btn-warning" value="重置" />
				</div>
			</form>
		</div>
	</body>
</html>

12、 AlertStudent.jsp页面的代码,这是实现更新操作的页面,与DaoAddStudent.jsp类。

<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.Statement"%>
<%@ 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>
<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>
<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-11" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/DaoAlertStudent.jsp">
<%
	//修改学生资料

	if((String)session.getAttribute("logname")==null){
		out.print("<script language='JavaScript'>alert('请先登录!');window.location.href='Login.html'</script>");
	}

	request.setCharacterEncoding("UTF-8");
	String sourceId = request.getParameter("sourceId");
	sourceId = sourceId.substring(1, sourceId.length()-1);//由于传值过来会被''括住,需要去除
	String mobile_version= request.getParameter("mobile_version");
	String mobile_name = request.getParameter("mobile_name");
	String mMobile_made = request.getParameter("mMobile_made");
	String mobile_price = request.getParameter("mobile_price");
	String mobile_mess= request.getParameter("mobile_mess");
	String mobile_pic= request.getParameter("mobile_pic");
	String id = request.getParameter("id");
	String sqlQuery = "UPDATE `mobileshop`.`mobileForm` SET `mobile_version` = ?, `mobile_name` = ?, `mMobile_made` = ?, `mobile_price` = ?, `mobile_mess` = ?, `mobile_pic` = ?, `id` = ? WHERE (`mobile_version` = ?)";
	String sqlid = "SELECT * FROM mobileshop.mobileForm where mobile_version='"+mobile_version+"'";
	Connection con = null;
	Statement stat = null;
	ResultSet rs = null;
	PreparedStatement ps = null;
	boolean flag = true;
	try{
		Class.forName("com.mysql.cj.jdbc.Driver");
		String URL = "jdbc:mysql://127.0.0.1:3306/mobileshop?useSSL=false&user=root&password=123456&serverTimezone=GMT%2B8";
		con = DriverManager.getConnection(URL);
		stat = con.createStatement();
		rs = stat.executeQuery(sqlid);	
		if(sourceId.equals(mobile_version)){
			flag = false;
		}
		/*//out.print(flag);
		out.print("<br/>"+sourceId);
		out.print("<br/>"+id);*/
		if(rs.next() && flag){
			out.print("<script type='text/javascript'>alert('标识号重复!请重新输入!');window.location.href = document.referrer;</script>");
		}else{
			ps = con.prepareStatement(sqlQuery);
			ps.setString(1,mobile_version);
			ps.setString(2,mobile_name);
			ps.setString(3,mMobile_made);
			ps.setString(4,mobile_price);
			ps.setString(5,mobile_mess);
			ps.setString(6,mobile_pic);
			ps.setString(7,id);
			ps.setString(8,sourceId);
			ps.executeUpdate();
			out.print("<script type='text/javascript'>alert('更改手机信息成功!');window.location.href='Contain.jsp?pages=1';</script>");
			ps.close();
		}
		rs.close();
		stat.close();
		con.close();
	}catch (Exception e){
			e.printStackTrace();
		}
		
		
%>
</body>
</html>

13、DaoDelete.jsp页面的代码,这是实现删除手机信息的操作。

<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@ 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>
<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>
<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-13" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/DaoDelete.jsp">
<% 

	//删除手机资料
	if((String)session.getAttribute("logname")==null){
		out.print("<script language='JavaScript'>alert('请先登录!');window.location.href='Login.html'</script>");
	}

	request.setCharacterEncoding("UTF-8");
	String mobile_version = request.getParameter("mobile_version");
	String sql = "DELETE FROM `mobileshop`.`mobileForm` WHERE (`mobile_version` = ?)";
	Connection con = null;
	PreparedStatement ps = null;
	try{
		String URL = "jdbc:mysql://127.0.0.1:3306/mobileshop?useSSL=false&user=root&password=123456&serverTimezone=GMT%2B8";
		con = DriverManager.getConnection(URL);
		ps = con.prepareStatement(sql);
		ps.setString(1,mobile_version);
		ps.executeUpdate();
		out.print("<script type='text/javascript'>alert('删除手机信息成功!');window.location.href='Contain.jsp?pages=1';</script>");
		ps.close();
		con.close();
	}catch(Exception e){
		e.printStackTrace();
	}
	
%>
</body>
</html>

14、Daosearch.jsp页面的代码,这是实现搜索手机信息的操作,可以通过手机名称或手机标识号进行查找。

<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ 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">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<!-- Bootstrap CSS -->
		<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
		<!-- Optional JavaScript -->
		<!-- jQuery first, then Popper.js, then Bootstrap JS -->
		<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
		<script type="text/javascript">
			function del() {
				if(!confirm("确认要删除?")) {
					window.event.returnValue = false;
				}
			}
		</script>
		<title>手机信息管理系统</title>
		<style type="text/css">
			body {
				/*background-color: #eee;*/
			}
			
			form h1 {
				display: inline-block;
				width: 820px;
			}
			
			.check {
				padding: 30px 30px;
			}
			
			form {
				display: inline;
			}
			
			.contain {
				width: 1000px;
				border-radius: 10px;
				border: 1px #bbb solid;
				background-color: #eee;
				padding-top: 20px;
			}
			
			button {
				margin-left: 10px;
			}
			
			.search {
				display: inline-block;
				margin-left: 500px;
			}
			
			.add {
				float: right;
				margin-right: 50px;
			}
		</style>
	<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>

	<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-15" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/DaoSearch.jsp">
		<div class="contain pull-left" data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-15" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/DaoSearch.jsp">
			<form action="DaoSearch.jsp" class="form-inline ">
				<h2>查询结果</h2>
				<div class="form-group search">
					<input type="text" name="check" class="form-control" placeholder="请输入查询手机名称或手机标识号" />
					<input type="submit" name="submit" class="btn" value="搜索" />

				</div>
			</form>
			<a href="AddStudent.jsp" target="_self"><button class="btn btn-primary add">添加手机信息</button></a>
			<div class="pull-left">
				<table class="table">
					<thead>
						<tr>
							<th>手机标识号</th>
							<th>手机名称</th>
							<th>手机厂商</th>
							<th>手机价格</th>
							<th>手机简介</th>
							<th>手机模型图</th>
							<th>手机类别号</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
	<%
	//查询功能
	if((String)session.getAttribute("logname")==null){
		out.print("<script language='JavaScript'>alert('请先登录!');window.location.href='Login.html'</script>");
	}
	
	request.setCharacterEncoding("UTF-8");
	String search = request.getParameter("check");
	String sqlQuery;
	if(search.matches("[0-9]+")){
		sqlQuery = "SELECT * FROM mobileshop.mobileForm where mobile_version='"+search+"'";
	}else{
		sqlQuery = "SELECT * FROM mobileshop.mobileForm where mobile_name='"+search+"'";
	}
	
	try{
		Class.forName("com.mysql.cj.jdbc.Driver");
		String URL = "jdbc:mysql://127.0.0.1:3306/mobileshop?useSSL=false&user=root&password=123456&serverTimezone=GMT%2B8";
		Connection con = DriverManager.getConnection(URL);
		Statement sql = con.createStatement();
		ResultSet rs = sql.executeQuery(sqlQuery);
		while(rs.next()){
			out.print("<tr>");
			out.print("<td>"+rs.getString(1)+"</td>");
			out.print("<td>"+rs.getString(2)+"</td>");
			out.print("<td>"+rs.getString(3)+"</td>");
			out.print("<td>"+rs.getString(4)+"</td>");
			out.print("<td>"+rs.getString(5)+"</td>");
			out.print("<td>"+rs.getString(6)+"</td>");
			out.print("<td>"+rs.getString(7)+"</td>");
			out.print("<td><a href='AlertStudent.jsp?id="+rs.getString(1)+"'><button class='btn btn-primary'>修改</button></a><a href='DaoDelete.jsp?id="+rs.getString(1)+"' onclick='javascript:return del();'><button class='btn btn-danger'>删除</button></a></td>");
			out.print("</tr>");
		}
		con.close();
	}catch(SQLException e){
		e.printStackTrace();
	}
%>

					</tbody>
				</table>
			</div>

		</div>
	</body>

</html>

 

15、Contain2.jsp页面的代码,这个页面是用来管理手机订单信息的,可以进行增删改查等简单操作。

<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ 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">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<!-- Bootstrap CSS -->
		<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
		<!-- Optional JavaScript -->
		<!-- jQuery first, then Popper.js, then Bootstrap JS -->
		<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
		<script type="text/javascript">
			function del() {
				if(!confirm("确认要删除?")) {
					window.event.returnValue = false;
				}
			}
		</script>
		<title>手机网后台管理系统</title>
		<style type="text/css">
			body {
				/*background-color: #eee;*/
			}
			
			form h1 {
				display: inline-block;
				width: 820px;
			}
			
			.check {
				padding: 30px 30px;
			}
			
			form {
				display: inline;
			}
			
			.contain {
				width: 1000px;
				border-radius: 10px;
				border: 1px #bbb solid;
				background-color: #eee;
				padding-top: 20px;
			}
			
			button {
				margin-left: 10px;
			}
			
			.search {
				display: inline-block;
				margin-left: 500px;
			}
			
			.add {
				float: right;
				margin-right: 50px;
			}
			.pageNav{
				margin-left: 200px;
			}
		</style>
	<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>

	<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-6" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/Contain2.jsp">
		<%
		request.setCharacterEncoding("UTF-8");
		String pages = request.getParameter("pages");//获取当前页数
		int pagesNo = Integer.parseInt(pages);//把当前页数从字符串转为整型
		int startLine = (Integer.parseInt(pages)-1)*10;//指定数据库从哪一行开始读取
		%>
		<div class="contain pull-left" data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-6" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/Contain2.jsp">
			<form action="DaoSearch2.jsp" class="form-inline ">
				<h2>订单信息管理</h2>
				<div class="form-group search">
					<input type="text" name="check" class="form-control" placeholder="请输入查询订单人用户名或订单序号" />
					<input type="submit" name="submit" value="搜索" />

				</div>
			</form>
			<a href="AddStudent2.jsp" target="_self"><button>添加订单信息</button></a>
			<div class="pull-left">
				<table class="table table-hover">
					<thead>
						<tr>
							<th>订单序号</th>
							<th>用户名</th>
							<th>订单简述</th>
							<th>订单总价</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
<%
	int pageSize = 10;//指定数据库一次读取多少行
	String sqlQuery = "SELECT * FROM mobileshop.orderForm limit "+startLine+","+pageSize;//对数据库进行伪分页读取,一次只能读10行
	String sqlAll = "SELECT * FROM mobileshop.orderForm";
	int pagesCount = 0;//用于数据库最后读出所有行后总共有多少页
	int lastRow = 0;//记录数据库的最后一行
	try{
		Class.forName("com.mysql.cj.jdbc.Driver");
		String URL = "jdbc:mysql://127.0.0.1:3306/mobileshop?useSSL=false&user=root&password=123456&serverTimezone=GMT%2B8";
		Connection con = DriverManager.getConnection(URL);
		Statement sql = con.createStatement();
		Statement stat = con.createStatement();
		ResultSet rs = sql.executeQuery(sqlQuery);
		ResultSet rsAll = stat.executeQuery(sqlAll);
		rsAll.last();
		lastRow = rsAll.getRow();//记录数据库最后一行
		while(rs.next()){
			out.print("<tr>");
			out.print("<td>"+rs.getString(1)+"</td>");
			out.print("<td>"+rs.getString(2)+"</td>");
			out.print("<td>"+rs.getString(3)+"</td>");
			out.print("<td>"+rs.getString(4)+"</td>");
			out.print("<td><a href='AlertStudent2.jsp?id="+rs.getString(1)+"'><button>修改</button></a><a href='DaoDelete2.jsp?id="+rs.getString(1)+"' onclick='javascript:return del();'><button>删除</button></a></td>");
			out.print("</tr>");
		}
		con.close();
	}catch(SQLException e){
		e.printStackTrace();
	}
%>

					</tbody>
				</table>
				<div class="pageNav">
					<ul class="pagination">
					<%
						int prePage;//上一页的页数
						if(pagesNo == 1){
							prePage = 1;//若当前页是第一页,则第一页只能是当前页
						}else{
							prePage = pagesNo - 1;//除了上述情况外上一页等于当前页-1页
						}
					%>
					<li class="page-item"><a class="page-link" href="Contain.jsp?pages=<%=prePage%>">上一页</a></li>
					<%
						pagesCount = (lastRow % pageSize == 0) ? (lastRow / pageSize) : (lastRow / pageSize +1);//计算数据库能读出来的全部页数
						int minpages = (pagesNo - 3 >0) ? (pagesNo - 3) : 1;//设定最小页,防止页数小于第一页
						int maxpages = (pagesNo + 3 >= pagesCount) ? (pagesCount) : (pagesNo+3);//设定最大页
						for(int i = minpages;i <=maxpages ;i++){
							if(i == pagesNo){//当前页和遍历出来的页数相等时,需要通过调用css里面的样式“active"进行高亮
								out.print("<li class='page-item active'>");
								out.print("<a class='page-link' href='Contain.jsp?pages="+i+"'>"+i+"</a>");
								out.print("</li>");
							}else{//输出每一个分页
								out.print("<li class='page-item'>");
								out.print("<a class='page-link' href='Contain.jsp?pages="+i+"'>"+i+"</a>");
								out.print("</li>");
							}
							
						}
							//out.print("<li class='page-item'>");
							//out.print("<a class='page-link' href='#>...</a>");
							//out.print("</li>");
						
					%>
					<%
						int nextPage;
						if(pagesNo == pagesCount){//下一页的原理和上一页同理
							nextPage = pagesCount;
						}else{
							nextPage = pagesNo + 1;
						}
					%>
					<li class="page-item"><a class="page-link" href="Contain.jsp?pages=<%=nextPage%>">下一页</a></li>
					</ul>
				</div>

			</div>

		</div>
	</body>

</html>

16、下面是AddStudent2.jsp和DaoAddStudent2.jsp页面的代码(按顺序),这两个代码是实现手机订单信息的添加,与添加手机信息的代码类似(AddStudent.jsp、DaoAddStudent.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">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<!-- Bootstrap CSS -->
		<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
		<!-- Optional JavaScript -->
		<!-- jQuery first, then Popper.js, then Bootstrap JS -->
		<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
		<title>Insert title here</title>
		<style type="text/css">
			.form-control {
				width: 300px;
				height: 30px;
				float: right;
			}
			
			select {
				width: 210px;
				height: 30px;
			}
			
			.submit {
				margin-left: 100px;
				margin-right: 30px;
			}
			
			.contain {
				width: 1000px;
				border: 1px #bbb solid;
				background-color: #eee;
				padding-top: 20px;
				border-radius: 10px;
			}
			
			label {
				display: inline-block;
				width: 100px;
				margin-right: 10px;
			}
			
			form {
				margin-left: 300px;
			}
		</style>
	<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>

	<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-1" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/AddStudent2.jsp">
	<%
		if((String)session.getAttribute("logname")==null){
			out.print("<script language='JavaScript'>alert('请先登录!');window.location.href='Login.html'</script>");
		}//提示登陆,并且在当前页面打开Login.html页面
	%>
		<div class="contain" data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-1" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/AddStudent2.jsp">
			<form action="DaoAddStudent2.jsp" method="post">
				<div class="form-group form-inline">
					<label for="id">订单序号:</label>
				<input type="text" class="form-control" id="id" name="id" maxlength="15" required="required" placeholder="请输入你的订单序号:">
				</div>
			<div class="form-group form-inline">
				<label for="logname">用户名:</label>
					<input type="text" class="form-control" id="logname" name="logname" required="required">
				</div>
				<div class="form-group form-inline">
					<label for="mess">订单简介:</label>
					<input type="text" class="form-control" id="mess" name="mess" required="required">
				</div>
				<div class="form-group form-inline">
					<label for="sum">订单总价:</label>
					<input type="text" class="form-control" id="sum" name="sum" required="required">
				</div>
				<div class="form-group form-inline">
					<input type="submit" id="" name="" class="btn btn-primary submit" value="添加"/><input type="reset" class="btn btn-warning" value="重置" />
				</div>
			</form>
		</div>
	</body>
</html>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.Statement"%>
<%@ 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>
<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>
<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-9" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/DaoAddStudent2.jsp">
<%

	//添加学生资料
	if((String)session.getAttribute("logname")==null){
		out.print("<script language='JavaScript'>alert('请先登录!');window.location.href='Login.html'</script>");
	}

	request.setCharacterEncoding("UTF-8");
	String id= request.getParameter("id");
	String logname = request.getParameter("logname");
	String mess = request.getParameter("mess");
	String sum = request.getParameter("sum");
	String sqlQuery = "INSERT INTO `mobileshop`.`orderForm` (`id`, `logname`, `mess`, `sum`) VALUES (?, ?, ?, ?)";
	String sqlid = "SELECT * FROM mobileshop.orderForm where id='"+id+"'";
	Connection con = null;
	Statement stat = null;
	ResultSet rs = null;
	PreparedStatement ps = null;
	try{
		Class.forName("com.mysql.cj.jdbc.Driver");
		String URL = "jdbc:mysql://127.0.0.1:3306/mobileshop?useSSL=false&user=root&password=123456&serverTimezone=GMT%2B8";
		con = DriverManager.getConnection(URL);
		stat = con.createStatement();
		rs = stat.executeQuery(sqlid);
		
		if(rs.next()){
			out.print("<script type='text/javascript'>alert('订单号重复!请重新输入!');window.location.href = document.referrer;</script>");
		}else{
			ps = con.prepareStatement(sqlQuery);
			ps.setString(1,id);
			ps.setString(2,logname);
			ps.setString(3,mess);
			ps.setString(4,sum);
			ps.executeUpdate();
			out.print("<script type='text/javascript'>alert('添加订单信息成功!');window.location.href='Contain2.jsp?pages=1';</script>");
			ps.close();
		}
		rs.close();
		stat.close();
		con.close();
	}catch (Exception e){
			e.printStackTrace();
		}
		
		
%>
</body>
</html>

17、下面是AlertStudent2.jsp和DaoAlertStudent2.jsp页面的代码(按顺序),这两个代码是实现手机订单信息的更新,与更新手机信息的代码类似(AlertStudent.jsp、DaoAlertStudent.jsp页面)

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ 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">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<!-- Bootstrap CSS -->
		<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
		<!-- Optional JavaScript -->
		<!-- jQuery first, then Popper.js, then Bootstrap JS -->
		<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
		<title>Insert title here</title>
		<style type="text/css">
			.form-control {
				width: 300px;
				height: 30px;
				float: right;
			}
			
			select {
				width: 210px;
				height: 30px;
			}
			
			.submit {
				margin-left: 100px;
				margin-right: 30px;
			}
			
			.contain {
				width: 1000px;
				border: 1px #bbb solid;
				background-color: #eee;
				padding-top: 20px;
				border-radius: 10px;
			}
			
			label {
				display: inline-block;
				width: 100px;
				margin-right: 10px;
			}
			
			form {
				margin-left: 300px;
			}
		</style>
	<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>

	<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-4" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/AlertStudent2.jsp">
	<%!
	String sourceId;
	String id;
	String logname;
	String mess;
	String sum;
	%>
	<%
	
		if((String)session.getAttribute("logname")==null){
			out.print("<script language='JavaScript'>alert('请先登录!');window.location.href='Login.html'</script>");
		}
	
		request.setCharacterEncoding("UTF-8");
		id = request.getParameter("id");
		String sqlid = "SELECT * FROM mobileshop.orderForm where id='"+id+"'";
		sourceId = id;
		try{
			Class.forName("com.mysql.cj.jdbc.Driver");
			String URL = "jdbc:mysql://127.0.0.1:3306/mobileshop?useSSL=false&user=root&password=123456&serverTimezone=GMT%2B8";
			Connection con = DriverManager.getConnection(URL);
			Statement sql = con.createStatement();
			ResultSet rs = sql.executeQuery(sqlid);
			if(rs.next()){
				id = rs.getString(1);
				logname = rs.getString(2);
				mess= rs.getString(3);
				sum = rs.getString(4);
				
				
			}
			rs.close();
			sql.close();
			con.close();
		}catch(Exception e){
			e.printStackTrace();
		}
		
	%>
		<div class="contain" data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-4" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/AlertStudent2.jsp">
			<form action="DaoAlertStudent2.jsp?sourceId='<%=sourceId %>'" method="post">
				<div class="form-group form-inline">
					<label for="id">订单号:</label>
				<input type="text" class="form-control" id="id" name="id" value='<%=id %>' required="required">
				</div>
			<div class="form-group form-inline">
				<label for="logname">用户名:</label>
					<input type="text" class="form-control" id="logname" name="logname" maxlength="15" value='<%=logname %>' required="required">
				</div>
				<div class="form-group form-inline">
				<label for="mess">订单简述:</label>
					<input type="text" class="form-control" id="mess" name="mess" maxlength="15" value='<%=mess %>' required="required">
				</div>
				<div class="form-group form-inline">
					<label for="sum">订单总价:</label>
					<input type="text" class="form-control" id="sum" name="sum" value='<%=sum %>' required="required">
				</div>
				<div class="form-group form-inline">
					<input type="submit" id="" name="" class="btn btn-primary submit" value='修改' /><input type="reset" class="btn btn-warning" value="重置" />
				</div>
			</form>
		</div>
	</body>
</html>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.Statement"%>
<%@ 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>
<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>
<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-12" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/DaoAlertStudent2.jsp">
<%
	//修改学生资料

	if((String)session.getAttribute("logname")==null){
		out.print("<script language='JavaScript'>alert('请先登录!');window.location.href='Login.html'</script>");
	}

	request.setCharacterEncoding("UTF-8");
	String id = request.getParameter("id");
	String sourceId = request.getParameter("sourceId");
	sourceId = sourceId.substring(1, sourceId.length()-1);//由于传值过来会被''括住,需要去除
	String  logname=request.getParameter("logname");
	String mess=request.getParameter("mess");
	String sum=request.getParameter("sum");
	String sqlQuery = "UPDATE `mobileshop`.`orderForm` SET `id` = ?, `logname` = ?, `mess` = ?, `sum` = ? WHERE (`id` = ?)";
	String sqlid = "SELECT * FROM mobileshop.orderForm where id='"+id+"'";
	Connection con = null;
	Statement stat = null;
	ResultSet rs = null;
	PreparedStatement ps = null;
	boolean flag = true;
	try{
		Class.forName("com.mysql.cj.jdbc.Driver");
		String URL = "jdbc:mysql://127.0.0.1:3306/mobileshop?useSSL=false&user=root&password=123456&serverTimezone=GMT%2B8";
		con = DriverManager.getConnection(URL);
		stat = con.createStatement();
		rs = stat.executeQuery(sqlid);
		if(sourceId.equals(id)){
			flag = false;
		}
		
		if(rs.next() && flag){
			out.print("<script type='text/javascript'>alert('订单序号重复!请重新输入!');window.location.href = document.referrer;</script>");
		}else{
			ps = con.prepareStatement(sqlQuery);
			ps.setString(1,id);
			ps.setString(2,logname);
			ps.setString(3,mess);
			ps.setString(4,sum);
			ps.setString(5,sourceId);
			ps.executeUpdate();
			out.print("<script type='text/javascript'>alert('修改订单信息成功!');window.location.href='Contain2.jsp?pages=1';</script>");
			ps.close();
		}
		rs.close();
		stat.close();
		con.close();
	}catch (Exception e){
			e.printStackTrace();
		}
		
		
%>
</body>
</html>

18、DaoDelete2.jsp页面的代码,这是实现手机订单信息的删除功能,可以通过直接点击记录进行删除(其实是通过你点击的记录的订单号,然后去数据库中搜索该订单号的记录进行删除)

<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@ 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>
<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>
<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-14" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/DaoDelete2.jsp">
<% 

	//删除学生资料
	if((String)session.getAttribute("logname")==null){
		out.print("<script language='JavaScript'>alert('请先登录!');window.location.href='Login.html'</script>");
	}

	request.setCharacterEncoding("UTF-8");
	String id = request.getParameter("id");
	String sql = "DELETE FROM `mobileshop`.`orderForm` WHERE (`id` = ?)";
	Connection con = null;
	PreparedStatement ps = null;
	try{
		String URL = "jdbc:mysql://127.0.0.1:3306/mobileshop?useSSL=false&user=root&password=123456&serverTimezone=GMT%2B8";
		con = DriverManager.getConnection(URL);
		ps = con.prepareStatement(sql);
		ps.setString(1,id);
		ps.executeUpdate();
		out.print("<script type='text/javascript'>alert('删除订单信息成功!');window.location.href='Contain2.jsp?pages=1';</script>");
		ps.close();
		con.close();
	}catch(Exception e){
		e.printStackTrace();
	}
	
%>
</body>
</html>

19、DaoSearch2.jsp页面的代码,这是用来搜索手机订单信息的操作,可以通过订单号或者订单用户的用户名来进行搜索,从而达到筛选的目的。

<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ 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">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<!-- Bootstrap CSS -->
		<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
		<!-- Optional JavaScript -->
		<!-- jQuery first, then Popper.js, then Bootstrap JS -->
		<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
		<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
		<script type="text/javascript">
			function del() {
				if(!confirm("确认要删除?")) {
					window.event.returnValue = false;
				}
			}
		</script>
		<title>订单信息管理系统</title>
		<style type="text/css">
			body {
				/*background-color: #eee;*/
			}
			
			form h1 {
				display: inline-block;
				width: 820px;
			}
			
			.check {
				padding: 30px 30px;
			}
			
			form {
				display: inline;
			}
			
			.contain {
				width: 1000px;
				border-radius: 10px;
				border: 1px #bbb solid;
				background-color: #eee;
				padding-top: 20px;
			}
			
			button {
				margin-left: 10px;
			}
			
			.search {
				display: inline-block;
				margin-left: 500px;
			}
			
			.add {
				float: right;
				margin-right: 50px;
			}
		</style>
	<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>

	<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-16" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/DaoSearch2.jsp">
		<div class="contain pull-left" data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-16" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/DaoSearch2.jsp">
			<form action="DaoSearch.jsp" class="form-inline ">
				<h2>查询结果</h2>
				<div class="form-group search">
					<input type="text" name="check" class="form-control" placeholder="请输入查询订单人用户名或订单序号" />
					<input type="submit" name="submit" class="btn" value="搜索" />

				</div>
			</form>
			<a href="AddStudent2.jsp" target="_self"><button class="btn btn-primary add">添加订单信息</button></a>
			<div class="pull-left">
				<table class="table">
					<thead>
						<tr>
							<th>订单序号</th>
							<th>用户名</th>
							<th>订单简述</th>
							<th>订单总价</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
	<%
	//查询功能
	if((String)session.getAttribute("logname")==null){
		out.print("<script language='JavaScript'>alert('请先登录!');window.location.href='Login.html'</script>");
	}
	
	request.setCharacterEncoding("UTF-8");
	String search = request.getParameter("check");
	String sqlQuery;
	if(search.matches("[0-9]+")){
		sqlQuery = "SELECT * FROM mobileshop.orderForm where id='"+search+"'";
	}else{
		sqlQuery = "SELECT * FROM mobileshop.orderForm where logname='"+search+"'";
	}
	
	try{
		Class.forName("com.mysql.cj.jdbc.Driver");
		String URL = "jdbc:mysql://127.0.0.1:3306/mobileshop?useSSL=false&user=root&password=123456&serverTimezone=GMT%2B8";
		Connection con = DriverManager.getConnection(URL);
		Statement sql = con.createStatement();
		ResultSet rs = sql.executeQuery(sqlQuery);
		while(rs.next()){
			out.print("<tr>");
			out.print("<td>"+rs.getString(1)+"</td>");
			out.print("<td>"+rs.getString(2)+"</td>");
			out.print("<td>"+rs.getString(3)+"</td>");
			out.print("<td>"+rs.getString(4)+"</td>");
			out.print("<td><a href='AlertStudent2.jsp?id="+rs.getString(1)+"'><button class='btn btn-primary'>修改</button></a><a href='DaoDelete2.jsp?id="+rs.getString(1)+"' onclick='javascript:return del();'><button class='btn btn-danger'>删除</button></a></td>");
			out.print("</tr>");
		}
		con.close();
	}catch(SQLException e){
		e.printStackTrace();
	}
%>

					</tbody>
				</table>
			</div>

		</div>
	</body>

</html>

20,AdminPasswordReset.jsp的页面代码,这是修改代码的页面,需要你输入新的密码,然后通过表单来提交给DaoAdminPasswordRest.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">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<title>Insert title here</title>
<style type="text/css">
	.container{
		width: 1000px;
		border: 1px #bbb solid;
		background-color: #eee;
		padding-top: 20px;
		border-radius: 10px;
		float: left;
	}
	.form-control{
		width: 300px;
		height: 30px;
	}
	form {
		margin-left: 300px;
	}
	.submit{
		margin-left: 50px;
	}
	.reset{
		margin-left: 50px;
	}
</style>
<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>
<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-2" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/AdminPasswordReset.jsp">
	<%
	if((String)session.getAttribute("logname")==null){
		out.print("<script language='JavaScript'>alert('请先登录!');window.location.href='Login.html'</script>");
	}
	%>
<div class="container" data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-2" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/AdminPasswordReset.jsp">
  <h2>管理员账户密码修改</h2>
  <form action="DaoAdminPasswordReset.jsp" method="post">
    <div class="form-group">
      <label for="logname">用户名</label>
      <input type="email" class="form-control" id="logname" name="logname"  readonly="readonly" value="<%= session.getAttribute("logname")%>">
    </div>
    <div class="form-group">
      <label for="pwd">密码</label>
      <input type="password" class="form-control" id="pwd" name="pwd" placeholder="请输入新的密码">
    </div>
    <button type="submit" class="btn btn-danger submit">修改</button>
    <input type="reset" class="btn btn-warning reset" id="reset" value="重置" />
  </form>
</div>
</body>
</html>

21、DaoAdminPasswordReset.jsp页面的代码,这是通过request获取表单提交过来的数据,然后连接login表进行更新管理员的密码。

<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@ 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>
<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"52136",secure:"52141"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>
<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc2-10" data-genuitec-path="/StudentManagementSystemByWeb/WebContent/DaoAdminPasswordReset.jsp">
<%
	//修改管理员的密码
	String logname = session.getAttribute("logname").toString();
	String realname = session.getAttribute("realname").toString();
	String passowrd = request.getParameter("pwd");
	String sql = "UPDATE `mobileshop`.`login` SET `password` = ? WHERE (`realname` = ?)";
	Connection con = null;
	PreparedStatement ps = null;
	try{
		Class.forName("com.mysql.cj.jdbc.Driver");
		String URL = "jdbc:mysql://127.0.0.1:3306/mobileshop?useSSL=false&user=root&password=123456&serverTimezone=GMT%2B8";
		con = DriverManager.getConnection(URL);
		ps = con.prepareStatement(sql);
		ps.setString(1, passowrd);
		ps.setString(2, realname);
		ps.executeUpdate();
		ps.close();
		con.close();
		session.removeAttribute("realname");//移除用户会话
		session.removeAttribute("logname");
		out.print("<script type='text/javascript'>alert('更改密码成功!请重新登录!');window.parent.frames.location.href='Login.html';</script>");
	}catch(Exception e){
		e.printStackTrace();
	}
%>
</body>
</html>

四、数据库表截图(数据库的表结构以及数据已导出并上传至顶部的百度网盘链接):

 

五、总结

      至此,我的智多星手机销售管理系统的设计就到此顺利完成。总结本次实验本次的遗憾是由于时间比较紧急,所以老师直接给了我们前端的源码,但是,就算是源码,在前端的运行过程中还是出现比较多的细节问题,比如不能直接导入老师给的源代码文件、数据加载驱动的语句(驱动jar在8.0后的版本需要把加载驱动语句改为:Class.forName("com.mysql.cj.jdbc.Driver");)以及数据的连接语句需要修改(需要在url语句最后面加上&serverTimezone=GMT%2B8",否则会出现异常,百度了一下据说是跟时间戳有关),磕磕绊绊地最终还是在老师给定的期限内勉强地实现了整个手机销售管理系统。我接下来的空余时间内,我会把系统好好完善,最好是能够自己把前端的功能给实现一遍,而不是只由自己编写了后台代码,搞得自己需要花时间去理解代码,还要不断地调试陌生的代码。在实现后台的过程中,我了解到了bootstrap语言,这个语言是一种响应式布局设计,可以让一个网站可以兼容不同分辨率的设备。Bootstrap响应式布局设计,给用户提供更好的视觉使用体验、丰富的组件、高大上:界面美观上档次、未来向所有项目、平台推广,十分耐用,值得推荐大家去学习一下。最后,学无止境,我希望在接下来的生活中能够更好地认识到编程的乐趣,在兴趣中不断进步。

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值