暑假第一周总结

本周主要在完成关于数据库原理课程的小学期任务,所选题目——食堂管理系统。

本系统主要实现对基于Javaweb食堂信息管理系统所需的各项基本功能,能够对食品信息进行增删改查等功能,并可以实现用户注册、用户登陆等功能。

数据库:Mysql

开发工具:Eclipse

开发环境:JDK+Tomcat

目前大概的功能展示如下:

登录界面:

 

主页面:

 

 login.jsp代码:

<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="css/login.css" type="text/css" rel="stylesheet">
<title>食堂管理系统登陆界面</title>
</head>
<body>
<form action="CheckLoginServlet" method="post">
<div class="content">
<div class="wrap">
<div class="login-box">
<div class="login-frame">
<h2>
用户登录
</h2>
<div class="item">
<input type="text" name="UID" placeholder="用户名">
</div>
<div class="item">
<input type="password" name="upwd" placeholder="密码">
</div>
<input type="submit" class="login-btn" value="登 录">

<%
String error = (String) request.getAttribute("error");
String error0 = (String) request.getAttribute("error0");
String error1 = (String) request.getAttribute("error1");
String error2 = (String) request.getAttribute("error2");
String error3 = (String) request.getAttribute("error3");
String error4 = (String) request.getAttribute("error4");

if (error != null) {
if (error.equals("loginError")) {
out.println("用户名或密码错误!登录失败!");
} else if (error.equals("nologinError")) {
response.sendRedirect("QueryStudentByPageServlet");
}
}

if (error0 != null) {
if (error0.equals("loginError")) {
out.println("用户名或密码错误!修改失败!");
} else if (error0.equals("nologinError")) {
if (error1 != null) {
if (error1.equals("noupdateError")) {
out.println("密码修改成功!");
}
}
}
}
if (error2 != null) {
if (error2.equals("loginError")) {
out.println("用户名或密码错误!注销失败!");
} else if (error2.equals("nologinError")) {
if (error3 != null) {
if (error3.equals("nodeleteError")) {
out.println("账户注销成功!");
}
}
}
}
if (error4 != null) {
if (error4.equals("noaddError")) {
out.println("账户注册成功!");
}
}
%>
</div>
</div>
</div>
</div>
</form>
</body>
</html>

login.css代码:

@charset "UTF-8";
*{margin:0;padding:0;}
a{text-decoration:none;color:#666;}
a:hover{
text-decoration:underline;
color:E4393C;
}
html,body
{
font:12px/150% Arial,Verdana;
}

.wrap{
width:1000px;
margin:0 auto;
}
.left{
float:left;
}

.content{
background:url(../image/login.jpg);
background-size: cover;
width:1280px;
height:559px;
}

.login-frame{
margin:50px 5% 50px 5%;
float:right;
padding:60px;
background:white;
background-color:rgba(255,255,255,0.9);
border-radius:25px;
order-right:1px #bdbdbd solid;
width:280px;
height:230px;
}


.login-frame h2{
font-size:25px;
height:40px;
margin-buttom:25px;
}
.login-frame h2 a{
font-size:15px;
color:#59c2c5;
padding-left:20px;
background:url(../image/icon5.jpg);
}

.login-frame .item{
height:60px;
margin-buttom:40px;
}

.login-frame .item input{
line-height:40px;
width:260px;
border:none;
border-bottom: 1px solid #59c2c5;
}

.login-btn{
display:block;
height:50px;display:block;
height:50px;
color:#fff;
background:#59c2c5;
width:265px;
font-size:16px;
line-height:30px;
text-align:center;
border-radius:10px;
border:none;
color:#fff;
background:#59c2c5;
width:265px;
font-size:16px;
line-height:30px;
text-align:center;
border-radius:10px;
border:none;
}
.login-frame .item1{
dislpay:flex;
justify-content: space-between;
margin-top:1 rem;
}
.login-frame .item1 a{
line-height:40px;
font-size:1.1rem;
margin-top:5 rem;
padding:1rem 3rem;
}

index.jsp代码:

<%@page import="Beans.Page"%>

<%@page import="Beans.foodBean"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<script type = "text/javascript" src = "js/jquery-3.6.0.js"></script>

<script type = "text/javascript">
$(document).ready(function(){
$("tr:odd").css("background-color","lightgrey");

});
</script>

<link href="css/show.css" type="text/css" rel="stylesheet">
<meta charset="UTF-8">
<title>食品信息列表</title>
</head>
<body>

<div class = "content">
<div class = "box">
<table border="2" cellspacing="0">
<tr>
<th><h2>食品ID</h2></th>
<th><h2>食品名称</h2></th>
<th><h2>食品价格</h2></th>
<th><h2>食品介绍</h2></th>
<th><h2>店铺ID</h2></th>
<th><h2>操作</h2></th>
</tr>
<%
Page page1 = (Page)request.getAttribute("page1");

for(foodBean bean:page1.getfoods()){
%>
<tr>
<td><a href = "QueryStudentBySnoServlet?sno=<%=bean.getId()%>"><%=bean.getId() %></a></td>
<td><%=bean.getName() %></td>
<td><%=bean.getPrice() %></td>
<td><%=bean.getIntroduce() %></td>
<td><%=bean.getDPid() %></td>
<td><a href = "DeleteStudentServlet?sno=<%=bean.getId() %>">删除</a></td>
</tr>
<%
}
%>
</table>
<div class = item>
<a href = "add.jsp">增加食品</a>
</div>
<%
if(page1.getCurrentPage()==page1.getTotalPage()-1){
%>
<div class = item>
<a href = "QueryStudentByPageServlet?currentPage=0">首页</a>
<a href = "QueryStudentByPageServlet?currentPage=<%=page1.getCurrentPage()-1%>">上一页</a>
</div>
<%
}
else if(page1.getCurrentPage()==0){
%>
<div class = item>
<a href = "QueryStudentByPageServlet?currentPage=<%=page1.getCurrentPage()+1%>">下一页</a>
<a href = "QueryStudentByPageServlet?currentPage=<%=page1.getTotalPage()-1%>">尾页</a>
</div>
<%
}
else{
%>
<div class = item>
<a href = "QueryStudentByPageServlet?currentPage=0">首页</a>
<a href = "QueryStudentByPageServlet?currentPage=<%=page1.getCurrentPage()-1%>">上一页</a>
<a href = "QueryStudentByPageServlet?currentPage=<%=page1.getCurrentPage()+1%>">下一页</a>
<a href = "QueryStudentByPageServlet?currentPage=<%=page1.getTotalPage()-1%>">尾页</a>
</div>
<%
}
%>
<%
String error = (String)request.getAttribute("error");
if(error!=null){
if(error.equals("addError")){
out.println("增加失败!");
}
else if(error.equals("noaddError")){
out.println("增加成功!");
}
}

String error1 = (String)request.getAttribute("error1");
if(error1!=null){
if(error1.equals("deleteError")){
out.println("删除失败!");
}
else if(error1.equals("nodeleteError")){
out.println("删除成功!");
}
}
String error2 = (String)request.getAttribute("error2");
if(error2!=null){
if(error2.equals("updateError")){
out.println("修改失败!");
}
else if(error2.equals("noupdateError")){
out.println("修改成功!");
}
}


String error3 = (String)request.getAttribute("error3");
if(error3!=null){
if(error3.equals("uploadError")){
out.println("上传失败!");
}
else if(error3.equals("nouploadError")){
out.println("上传成功!");
}
}
%>
</div>
</div>
</body>
</html>

show.css代码:

@charset "UTF-8";

*{margin:0;padding:0;}
html,body
{
font:12px/150% Arial,Verdana;
}
.content{
background:url(../image/index.JPG);
background-size: cover;
width:1280px;
height:559px;
}
.box{
margin:60px 18% 60px 18%;
float:right;
padding:30px;
background:white;
background-color:rgba(255,255,255,0.9);
border-radius:15px;

}
.item{
height:40px;

border-radius:15px;
}
.item a{
background-color: lightgrey;
text-decoration: none;
font-size:15px;
color:black;
border-radius:3px;
}
.item1{
font-size:15px;
height:40px;
}
table{
width:100%;
border-collapse:collapse;
}
table body{
diaplay:block;
height:300px;
overflow-y: scroll;
}
table td{
border:1px solid #A6A6A6;
height:60px;
width:300px;
text-align: center;
font-size: 15px;
}
table th{
height:60px;
border:1px solid #A6A6A6;
}

 

posted @ 2022-07-02 20:10  一个小弱鸡  阅读(38)  评论(0编辑  收藏  举报