一、系统介绍
软件环境
IDEA:2018.2
Java:jdk1.8
Mysql:8.0.13
Tomcat:8.5.23
系统功能
1.用户的注册与登录
2.宠物信息的增删改查
3.医生信息的增删改查。
数据库涉及的表
userinfo
petdoctor
petdetalis
二、系统展示
1.登录
2.注册
3.宠物查询主页面
4.宠物查询结果
5.宠物信息修改
6.宠物信息新增
7.医生查询主界面
8.医生查询结果
9.医生信息修改
10.医生信息新增
三、代码实现
1.前端
init.jsp
<%@ page language="java" pageEncoding="UTF-8" %> <% session.setAttribute("error", "test"); %> <jsp:forward page="login.jsp"></jsp:forward>
login.jsp
<%@ page language="java" pageEncoding="UTF-8" %> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <base href="<%=basePath%>"> <title>请登录</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="css/css.css" rel="stylesheet" type="text/css"> <style type="text/css"> #content { position: relative; top: 3px; width: 80%; height: 380px; margin: auto; overflow: hidden; z-index: 2; } .tab1 { position: relative; top: 100px; font-size: 24px; } #in1 { width: 250px; height: 30px; font-size: 24px; } #in3 { width: 250px; height: 30px; font-size: 24px; } #in2 { width: 80px; height: 28px; } </style> <script type="text/javascript"> function checkId() { if (document.getElementById("in1").value == "" && document.getElementById("in3").value == "") { alert("请输入用户名和密码!"); return false; } else if (document.getElementById("in1").value == "") { alert("请输入用户名"); return false; } else if (document.getElementById("in3").value == "") { alert("请输入密码!"); return false; } else { return true; } } </script> </head> <body> <% if (session.getAttribute("error").equals("error")) { %> <script type="text/javascript"> alert("用户名或密码错误请重新登录!"); </script> <% } session.setAttribute("error", "test"); %> <div id="top"> <font class="topc">宠物诊所</font> </div> <center> <div id="content"> <form action="servlet/loginservlet" method="post" onsubmit="return checkId()"> <table border="0" cellpadding="0" cellspacing="2" class="tab1"> <tr align="center"> <td>用户名</td> <td><input type="text" name="username" id="in1"/></td> </tr> <tr align="center"> <td>密 码</td> <td><input type="password" name="password" id="in3"/></td> </tr> <tr> <td align="center" colspan="2"> <input type="submit" value="登录" id="in2"/> <input type="reset" value="重置" id="in2"/> <a href="adduser.jsp"><font color="gray" size="3"><i>注册</i></font></a> </td> </tr> </table> </form> </div> </center> <!-- include footer --> <jsp:include page="footer.jsp"></jsp:include> </body> </html>
adduser.jsp
<%@ page language="java" pageEncoding="UTF-8" %> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <base href="<%=basePath%>"> <title>注册</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="css/css.css" rel="stylesheet" type="text/css"> <style type="text/css"> #content { position: relative; top: 3px; width: 80%; height: 380px; margin: auto; overflow: hidden; z-index: 2; } .tab1 { position: relative; top: 60px; font-size: 24px; } #in1, #in2, #in3, #in4 { width: 250px; height: 30px; font-size: 24px; } #in5 { width: 80px; height: 28px; margin-top: 10px; } </style> <script type="text/javascript"> function checkId() { if (document.getElementById("in1").value == "" && document.getElementById("in3").value == "" && document.getElementById("in2").value == "") { alert("请输入注册用户名和密码!"); return false; } else if (document.getElementById("in1").value == "") { alert("请输入用户名"); return false; } else if (document.getElementById("in3").value == "") { alert("请输入密码!"); return false; } else if (document.getElementById("in2").value == "") { alert("请输入确认密码!"); return false; } else if (document.getElementById("in3").value != document.getElementById("in2").value) { alert("您两次的密码不相同!"); document.getElementById("in2").value = ""; document.getElementById("in3").value = ""; return false; } else { return true; } } </script> </head> <body> <div id="top"> <font class="topc">注册</font> </div> <center> <div id="content"> <br/> <form action="servlet/addUserSer" method="post" onsubmit="return checkId()"> <table border="0" cellpadding="0" cellspacing="2" class="tab1"> <tr align="center"> <td>用户名 </td> <td><input type="text" name="name" id="in1"/>* </td> </tr> <tr align="center"> <td>密 码 </td> <td><input type="password" name="password" id="in3"/>* </td> </tr> <tr align="center"> <td>确认密码 </td> <td><input type="password" id="in2"/>* </td> </tr> <tr align="center"> <td>电 话 </td> <td><input type="text" name="phone" id="in4"/> </td> </tr> <tr align="center"> <td colspan="2"> <input type="submit" value="提交" id="in5"/> <input type="reset" value="重置" id="in5"/> </td> </tr> </table> </form> </div> </center> <!-- include footer --> <jsp:include page="footer.jsp"></jsp:include> </body> </html>
adderr.jsp
<%@ page language="java" pageEncoding="UTF-8" %> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <base href="<%=basePath%>"> <title>失败</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="css/css.css" rel="stylesheet" type="text/css"> <style type="text/css"> #content { position: relative; top: 3px; width: 80%; height: 380px; margin: auto; overflow: hidden; font-size: 30px; z-index: 2; } </style> </head> <body> <div id="top"> <font class="topc">注册失败</font> </div> <center> <div id="content"> <br/><br/> <br/>(╯﹏╰) 注册失败,返回重新注册 <a href="adduser.jsp"> <font color="blue"> <i>返回</i> </font> </a> </div> </center> <!-- include footer --> <jsp:include page="footer.jsp"></jsp:include> </body> </html>
addsuc.jsp
<%@ page language="java" pageEncoding="UTF-8" %> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <base href="<%=basePath%>"> <title>恭喜注册成功</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="refresh" content="3;url=../init.jsp"> <link href="css/css.css" rel="stylesheet" type="text/css"> <style type="text/css"> #content { position: relative; top: 3px; width: 80%; height: 380px; margin: auto; overflow: hidden; font-size: 30px; z-index: 2; } </style> </head> <body> <div id="top"> <font class="topc">注册成功</font> </div> <center> <div id="content"> <br/><br/> <br/> (*^__^*)恭喜您注册成功!3s后返回登录页面 <a href="init.jsp"> <font color="red"> <i>立即返回</i> </font> </a> </div> </center> <!-- include footer --> <jsp:include page="footer.jsp"></jsp:include> </body> </html>
petadd.jsp
<%@ page language="java" pageEncoding="UTF-8" %> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <base href="<%=basePath%>"> <title>宠物新增</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="css/css.css" rel="stylesheet" type="text/css"> <style type="text/css"> #content { position: relative; top: 3px; width: 80%; height: 380px; margin: auto; overflow: hidden; z-index: 2; } .tab1 { position: relative; top: 60px; font-size: 24px; } #in1, #in2, #in3, #in4 ,#in6{ width: 250px; height: 30px; font-size: 24px; } #in5 { width: 80px; height: 28px; margin-top: 10px; } </style> <script type="text/javascript"> function checkId() { if (document.getElementById("in1").value == "" && document.getElementById("in3").value == "" && document.getElementById("in2").value == "" && document.getElementById("in6").value == "") { alert("请输入宠物名相关信息!"); return false; } else if (document.getElementById("in1").value == "") { alert("请输入宠物名!"); return false; } else if (document.getElementById("in3").value == "") { alert("请输入主人!"); return false; }else if (document.getElementById("in6").value == "") { alert("请输入电话!"); return false; } else { return true; } } </script> </head> <body> <jsp:include page="top.jsp"></jsp:include> <!-- include top --> <center> <div id="content"> <br/> <form action="servlet/petadd" method="post" onsubmit="return checkId()"> <table border="0" cellpadding="0" cellspacing="2" class="tab1"> <tr align="center"> <td>宠物名 </td> <td><input type="text" name="petname" id="in1"/>* </td> </tr> <tr align="center"> <td>主人 </td> <td><input type="text" name="petmaster" id="in3"/>* </td> </tr> <tr align="center"> <td>城市 </td> <td><input type="text" name="petcity" id="in4"/> </td> </tr> <tr align="center"> <td>地址 </td> <td><input type="text" name="petadress" id="in2"/> </td> </tr> <tr align="center"> <td>电话 </td> <td><input type="text" name="petphone" id="in6"/>* </td> </tr> <tr align="center"> <td colspan="2"> <input type="submit" value="提交" id="in5"/> <input type="reset" value="重置" id="in5"/> </td> </tr> </table> </form> </div> </center> <!-- include footer --> <jsp:include page="footer.jsp"></jsp:include> </body> </html>