Co-authored-by: p9fu3l5ok <569968567@qq.com>
Co-committed-by: p9fu3l5ok <569968567@qq.com>
develop
p9fu3l5ok 5 months ago committed by pscmholb5
parent a60905a41e
commit 4667f9fa56

@ -1,67 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>图书管理员登录页面</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<!-- 可选的 Bootstrap 主题文件(一般不用引入) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<link rel="stylesheet" href="./public/css/animate.css">
<link rel="stylesheet" href="./public/css/login.css" />
<!DOCTYPE html> <!-- 声明文档类型为HTML5 -->
<html> <!-- HTML文档的根元素 -->
<head> <!-- head元素包含元数据 -->
<meta charset="UTF-8"> <!-- 设置字符编码为UTF-8 -->
<title>图书管理员登录页面</title> <!-- 设置网页标题 -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <!-- 设置视口属性,使页面在移动设备上正常显示 -->
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<!-- 可选的 Bootstrap 主题文件(一般不用引入) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<link rel="stylesheet" href="./public/css/animate.css"> <!-- 引入动画样式表 -->
<link rel="stylesheet" href="./public/css/login.css" /> <!-- 引入自定义登录样式表 -->
</head>
<body>
<div class="container main">
<div id="login" class="contain animated fadeInDown">
<h1>工作人员登录</h1>
<form method="post">
<input type="text" name="user" class="form-control my_input" placeholder="请输入账号" required="required">
<input type="password" name="psw" class="form-control my_input" placeholder="请输入密码" required="required">
<input type="submit" class="form-control" value="登录" onclick="javascript:void(0);">
</form>
</div>
</div>
<div style="position:fixed; bottom:0; right:0;">
<a href="reader/04readerFrame.jsp" target="_blank"><img src="public/image/reader.png" width="50px" height="50px"></a><br>
<a href="adminLogin.html" target="_blank"><img src="public/image/admin.png" width="50px" height="50px"></a>
<body> <!-- body元素包含网页内容 -->
<div class="container main"> <!-- 主容器 -->
<div id="login" class="contain animated fadeInDown"> <!-- 登录表单容器,带有动画效果 -->
<h1>工作人员登录</h1> <!-- 登录标题 -->
<form method="post"> <!-- 表单使用POST方法提交 -->
<input type="text" name="user" class="form-control my_input" placeholder="请输入账号" required="required"> <!-- 用户名输入框 -->
<input type="password" name="psw" class="form-control my_input" placeholder="请输入密码" required="required"> <!-- 密码输入框 -->
<input type="submit" class="form-control" value="登录" onclick="javascript:void(0);"> <!-- 提交按钮 -->
</form>
</div>
</div>
<div style="position:fixed; bottom:0; right:0;"> <!-- 固定位置的链接容器 -->
<a href="reader/04readerFrame.jsp" target="_blank"><img width="50px" height="50px"></a><br> <!-- 读者管理链接 -->
<a href="adminLogin.html" target="_blank"><img width="50px" height="50px"></a> <!-- 管理员登录链接 -->
</div>
<script src="./public/js/layer/layer.js"></script>
<script>
$(function(){
//登录
$("input[type=submit]").click(function(){
$.ajax({
url: "./managerLogin",
type: "post",
data: $("form").serialize(),
dataType: "json",
success: function( data ){
if(data.code == 0){
layer.msg("登录成功", {
icon: 6,
time: 1000
}, function(){
location.href = data.url;
})
}else{
layer.open({
title: "登录失败",
content: data.msg,
icon: 5,
anim: 6
})
$(function(){ <!-- jQuery文档就绪函数 -->
//登录
$("input[type=submit]").click(function(){ <!-- 绑定点击事件到提交按钮 -->
$.ajax({ <!-- 发起Ajax请求 -->
url: "./managerLogin", <!-- 请求URL -->
type: "post", <!-- 请求类型为POST -->
data: $("form").serialize(), <!-- 序列化表单数据作为请求参数 -->
dataType: "json", <!-- 期望服务器返回JSON格式的数据 -->
success: function( data ){ <!-- 请求成功时的回调函数 -->
if(data.code == 0){ <!-- 如果返回码为0表示登录成功 -->
layer.msg("登录成功", { <!-- 弹出提示消息 -->
icon: 6, <!-- 图标类型 -->
time: 1000 <!-- 显示时间 -->
}, function(){
location.href = data.url; <!-- 跳转到指定URL -->
})
}else{ <!-- 如果返回码不为0表示登录失败 -->
layer.open({ <!-- 弹出错误提示框 -->
title: "登录失败", <!-- 提示框标题 -->
content: data.msg, <!-- 提示框内容 -->
icon: 5, <!-- 图标类型 -->
anim: 6 <!-- 动画效果 -->
})
}
}
}
})
return false; <!-- 阻止默认表单提交行为 -->
})
return false;
})
})
</script>
</body>
</html>

@ -1,85 +1,134 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
pageEncoding="UTF-8"%>
<!-- 页面指令设置页面语言为Java内容类型为HTML字符编码为UTF-8 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- 文档类型声明使用HTML 4.01 Transitional DTD -->
<html>
<head>
<meta charset="utf-8">
<meta charset="utf-8">
<!-- 设置页面字符编码为UTF-8 -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- 视口设置,确保页面在移动设备上正确显示 -->
<title>图书馆管理人员页面</title>
<link rel="stylesheet" href="../public/layui/css/layui.css">
<script src="../public/layui/layui.js"></script>
<!-- 页面标题 -->
<link rel="stylesheet" href="../public/layui/css/layui.css">
<!-- 引入LayUI的CSS样式文件 -->
</head>
<body class="layui-layout-body">
<!-- 页面主体部分应用LayUI布局类 -->
<div class="layui-layout layui-layout-admin">
<!-- LayUI布局容器应用管理员布局类 -->
<div class="layui-header">
<!-- 头部区域 -->
<div class="layui-logo">图书馆管理人员页面</div>
<!-- 网站Logo和标题 -->
<!-- 头部区域可配合layui已有的水平导航 -->
<ul class="layui-nav layui-layout-left">
<ul class="layui-nav layui-layout-left">
<!-- 左侧导航栏应用LayUI导航类 -->
<li class="layui-nav-item">
<a href="javascript:;">其它系统</a>
<a href=";">其它系统</a>
<!-- 导航项:其它系统 -->
<dl class="layui-nav-child">
<!-- 子菜单 -->
<dd><a href="../reader/04readerFrame.jsp" target="parent">图书馆首页</a></dd>
<!-- 子菜单项:图书馆首页 -->
<dd><a href="../adminLogin.html" target="parent">系统管理员</a></dd>
<!-- 子菜单项:系统管理员登录页 -->
</dl>
</li>
</ul>
<ul class="layui-nav layui-layout-right">
<!-- 右侧导航栏应用LayUI导航类 -->
<li class="layui-nav-item">
<a href="javascript:;">
<%=session.getAttribute("manager") %>
<a href=";">
<%=session.getAttribute("manager") %>
<!-- 动态显示当前登录的管理人员名称 -->
</a>
<dl class="layui-nav-child">
<dd><a href="09managerSelf.jsp" target="content">基本资料</a></dd>
<!-- 子菜单 -->
<dd><a href="09managerSelf.jsp" target="content">基本资料</a></dd>
<!-- 子菜单项:基本资料 -->
</dl>
</li>
<li class="layui-nav-item"><a href="./quit" target="_parent">退出</a></li>
<!-- 导航项:退出 -->
</ul>
</div>
<div class="layui-side layui-bg-black">
<!-- 左侧侧边栏,应用黑色背景类 -->
<div class="layui-side-scroll">
<!-- 滚动区域 -->
<!-- 左侧导航区域可配合layui已有的垂直导航 -->
<ul class="layui-nav layui-nav-tree" lay-filter="test">
<ul class="layui-nav layui-nav-tree" lay-filter="test">
<!-- 垂直导航树应用LayUI导航树类 -->
<li class="layui-nav-item layui-nav-itemed">
<a class="" href="javascript:;"><i class="layui-icon layui-icon-read" style="font-size: 20px; color: lightblue;"></i>&nbsp;图书管理</a>
<a class="" href=";"><i class="layui-icon layui-icon-read" style="font-size: 20px; color: lightblue;"></i>&nbsp;图书管理</a>
<!-- 主导航项:图书管理 -->
<dl class="layui-nav-child">
<!-- 子菜单 -->
<dd><a href="02borrow.jsp" target="content">借阅图书</a></dd>
<dd><a href="04judge.jsp;" target="content">归还图书</a></dd>
<!-- 子菜单项:借阅图书 -->
<dd><a href="04judge.jsp;" target="content">归还图书</a></dd>
<!-- 子菜单项:归还图书 -->
</dl>
</li>
<li class="layui-nav-item">
<a href="javascript:;"><i class="layui-icon layui-icon-form" style="font-size: 20px; color: orange;"></i>&nbsp;报表管理</a>
<a href=";"><i class="layui-icon layui-icon-form" style="font-size: 20px; color: orange;"></i>&nbsp;报表管理</a>
<!-- 主导航项:报表管理 -->
<dl class="layui-nav-child">
<!-- 子菜单 -->
<dd><a href="06borrowTable.jsp" target="content">借书报表</a></dd>
<!-- 子菜单项:借书报表 -->
<dd><a href="07returnTable.jsp" target="content">还书报表</a></dd>
<!-- 子菜单项:还书报表 -->
</dl>
</li>
<li class="layui-nav-item"><a href="08announcement.jsp" target="content"><i class="layui-icon layui-icon-release" style="font-size: 20px; color: yellow;"></i>&nbsp;发布公告</a></li>
<!-- 主导航项:发布公告 -->
</ul>
</div>
</div>
<div class="layui-body">
<!-- 内容主体区域 -->
<iframe src="02borrow.jsp" name="content" height="100%" width="100%" frameborder="0" ></iframe>
<iframe name="content" height="100%" width="100%" frameborder="0"></iframe>
<!-- 内嵌框架,用于加载不同页面内容 -->
</div>
<div class="layui-footer">
<!-- 底部固定区域 -->
© 图书管理系统
&#169; 图书管理系统
<!-- 版权信息 -->
</div>
</div>
<script src="../src/layui.js"></script>
<script>
//JavaScript代码区域
layui.use('element', function(){
var element = layui.element;
});
</script>
</body>
</html>
</html>

@ -1,114 +1,137 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
pageEncoding="UTF-8"%>
<!-- 设置页面语言为Java内容类型为HTML字符编码为UTF-8 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- 定义文档类型为HTML 4.01 Transitional -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
<script src="../public/layui/layui.js"></script>
<style>
.layui-form-label{
margin-left:20%;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- 设置页面的字符编码为UTF-8 -->
<title>Insert title here</title>
<!-- 设置页面标题 -->
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
<!-- 引入Layui的CSS样式文件 -->
<style>
.layui-form-label{
margin-left:20%;
}
</style>
<!-- 自定义样式将表单标签的左边距设置为20% -->
</head>
<body>
<div align="center" style=" margin-top: 2%;"><h1>借阅图书</h1></div>
<div align="center"
style="margin-left:30%; margin-top: 5%; width: 40%;">
<form class="layui-form layui-form-pane" action="03borrowSus.jsp">
<div class="layui-form-item">
<label class="layui-form-label">借阅证号</label>
<div class="layui-input-inline">
<input type="text" name="userid" lay-verify="required"
placeholder="请输入借阅证号" autocomplete="off" class="layui-input"><br>
</div>
<div align="center" style=" margin-top: 2%;"><h1>借阅图书</h1></div>
<!-- 居中显示标题“借阅图书”并设置顶部边距为2% -->
<div align="center"
style="margin-left:30%; margin-top: 5%; width: 40%;">
<!-- 设置表单容器的左外边距、上外边距和宽度 -->
<form class="layui-form layui-form-pane" action="03borrowSus.jsp">
<!-- 创建一个表单指定使用Layui的表单类并设置提交地址为03borrowSus.jsp -->
<div class="layui-form-item">
<label class="layui-form-label">借阅证号</label>
<!-- 创建表单标签,标签内容为“借阅证号” -->
<div class="layui-input-inline">
<input type="text" name="userid" lay-verify="required"
placeholder="请输入借阅证号" autocomplete="off" class="layui-input"><br>
<!-- 创建文本输入框名称为userid验证规则为必填占位符为“请输入借阅证号”自动完成关闭并应用Layui的输入框样式 -->
</div>
<div class="layui-form-item">
<label class="layui-form-label">图书编号</label>
<div class="layui-input-inline">
<input type="text" name="bookid" lay-verify="required"
placeholder="请输入图书编号" autocomplete="off" class="layui-input"><br>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">图书编号</label>
<!-- 创建表单标签,标签内容为“图书编号” -->
<div class="layui-input-inline">
<input type="text" name="bookid" lay-verify="required"
placeholder="请输入图书编号" autocomplete="off" class="layui-input"><br>
<!-- 创建文本输入框名称为bookid验证规则为必填占位符为“请输入图书编号”自动完成关闭并应用Layui的输入框样式 -->
</div>
<div class="layui-form-item">
<label class="layui-form-label">借阅日期</label>
<div class="layui-input-inline">
<input type="text" name="date1" id="date1" autocomplete="off"
class="layui-input"><br>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">借阅日期</label>
<!-- 创建表单标签,标签内容为“借阅日期” -->
<div class="layui-input-inline">
<input type="text" name="date1" id="date1" autocomplete="off"
class="layui-input"><br>
<!-- 创建文本输入框名称为date1ID为date1自动完成关闭并应用Layui的输入框样式 -->
</div>
</div>
<div class="layui-form-item" align="center">
<button class="layui-btn" lay-submit="" lay-filter="demo2">借阅</button>
</div>
</form>
<script>
layui
.use(
[ 'form', 'layedit', 'laydate' ],
function() {
var form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate;
//日期
laydate.render({
elem : '#date1',
type : 'datetime',
format : 'yyyy-M-d H:m:s',
value: new Date()
});
laydate.render({
elem : '#date2',
type : 'datetime',
format : 'yyyy-M-d H:m:s'
});
//创建一个编辑器
var editIndex = layedit
.build('LAY_demo_editor');
//监听提交
form.on('submit(demo1)', function(data) {
layer.alert(JSON.stringify(data.field), {
title : '最终的提交信息'
})
return false;
});
//表单赋值
layui.$('#LAY-component-form-setval').on(
'click', function() {
form.val('example', {
"username" : "贤心" // "name": "value"
,
"password" : "123456",
"interest" : 1,
"like[write]" : true //复选框选中状态
,
"close" : true //开关状态
,
"sex" : "女",
"desc" : "我爱 layui"
});
});
//表单取值
layui.$('#LAY-component-form-getval').on(
'click', function() {
var data = form.val('example');
alert(JSON.stringify(data));
});
});
</script>
</div>
<div class="layui-form-item" align="center">
<button class="layui-btn" lay-submit="" lay-filter="demo2">借阅</button>
<!-- 创建一个按钮应用Layui的按钮样式并设置点击时提交表单过滤器为demo2 -->
</div>
</form>
layui
.use(
[ 'form', 'layedit', 'laydate' ],
function() {
var form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate;
<!-- 加载Layui的form、layer、layedit和laydate模块 -->
//日期
laydate.render({
elem : '#date1',
type : 'datetime',
format : 'yyyy-M-d H:m:s',
value: new Date()
});
<!-- 渲染日期选择器绑定到ID为date1的元素类型为日期时间格式为“年-月-日 时:分:秒”,默认值为当前日期 -->
laydate.render({
elem : '#date2',
type : 'datetime',
format : 'yyyy-M-d H:m:s'
});
<!-- 渲染另一个日期选择器绑定到ID为date2的元素类型为日期时间格式为“年-月-日 时:分:秒” -->
//创建一个编辑器
var editIndex = layedit
.build('LAY_demo_editor');
//监听提交
form.on('submit(demo1)', function(data) {
layer.alert(JSON.stringify(data.field), {
title : '最终的提交信息'
})
return false;
});
//表单赋值
layui.$('#LAY-component-form-setval').on(
'click', function() {
form.val('example', {
"username" : "贤心" // "name": "value"
,
"password" : "123456",
"interest" : 1,
"like[write]" : true //复选框选中状态
,
"close" : true //开关状态
,
"sex" : "女",
"desc" : "我爱 layui"
});
});
//表单取值
layui.$('#LAY-component-form-getval').on(
'click', function() {
var data = form.val('example');
(JSON.stringify(data));
});
});
});
</script>
</div>
</body>
</html>

@ -1,163 +1,137 @@
<%@ page import="java.sql.*"%>
<%@ page import="javabean.EndTime"%>
<%@ page import="java.sql.*" %>
<%@ page import="javabean.EndTime" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="borrow" scope="session" class="javabean.JDBCBean"></jsp:useBean>
<%
String user = request.getParameter("userid");
String book = request.getParameter("bookid");
String date1 = request.getParameter("date1");
//String date2 = request.getParameter("date2");
String sql1 = "select * from borrow_card where ID =" + user;
ResultSet rs1 = borrow.executeQuery(sql1);
if(session.getAttribute("manager")!=null){
if (rs1.next()) {
String rule = rs1.getString("rule_id");
int cardstatus = Integer.parseInt(rs1.getString("STATUS"));
String sql4="select*from rules where id = "+rule;
ResultSet rs4 = borrow.executeQuery(sql4);
int n =0;
String library = "";
String[] libraryArray = {};
int num = 0;
while(rs4.next()){
n=rs4.getInt("limit_day");
library = rs4.getString("borrow_library");
libraryArray=library.split("、");
num = rs4.getInt("borrow_num");
}
EndTime endtime = new EndTime();
String end = endtime.show(n);
if(cardstatus!=0){
String sql2 = "select * from books where ID =" + book;
ResultSet rs2 = borrow.executeQuery(sql2);
if(rs2.next()){
int status=Integer.parseInt(rs2.getString("STATUS"));
String lib = Integer.toString(rs2.getInt("library_id"));
for(int z=0;z<libraryArray.length;z++){
//out.println(lib);
//out.println(libraryArray[z]);
if(libraryArray[z].equals(lib)){
String countSql = "select count(*) as count from borrow_books where manager_id is null and card_id ="+ user;
<jsp:useBean id="borrow" scope="session" class="javabean.JDBCBean"></jsp:useBean>
<%
String user = request.getParameter("userid"); // 获取请求参数中的用户ID
String book = request.getParameter("bookid"); // 获取请求参数中的图书ID
String date1 = request.getParameter("date1"); // 获取请求参数中的借阅日期
// String date2 = request.getParameter("date2"); // 获取请求参数中的归还日期(被注释掉)
ResultSet rsSql = borrow.executeQuery(countSql);
int count=0;
while(rsSql.next()){
count = rsSql.getInt("count");
}
//out.println(count);
if(count<num){
if(status==1){
String sql = "insert borrow_books(CARD_ID,BOOK_ID,BORROW_DATE,END_DATE)values('" + user + "','" + book
+ "','" + date1 + "','" + end + "');";
try {
int i = borrow.executeUpdate(sql);
if (i == 1) {
%>
<script>
alert('借阅成功!');
window.location.href = "02borrow.jsp";
</script>
<%
String sql3="update books set STATUS=0 where ID="+book;
borrow.executeUpdate(sql3);
} else {
%>
<script>
alert('借阅未成功!');
window.location.href = "02borrow.jsp";
</script>
<%
}
} catch (Exception e) {
%>
<script>
alert('借阅未成功!');
window.location.href = "02borrow.jsp";
</script>
<%
}
}else{
%>
<script>
alert('该图书已借出!');
window.location.href = "02borrow.jsp";
</script>
<%
}
}else{
%>
<script>
alert('该用户已达到可借阅数量!若需还借书,请先还书!');
window.location.href = "02borrow.jsp";
</script>
<%
}
}
if(z==libraryArray.length-1 && !libraryArray[z].equals(lib)){
%>
<script>
alert('该图书未在可借阅的图书馆内!');
window.location.href = "02borrow.jsp";
</script>
<%
}
}
}else{
%>
<script>
alert('该图书不存在!');
window.location.href = "02borrow.jsp";
</script>
<%
}
}else{
%>
<script>
alert('借阅证已挂失!');
window.location.href = "02borrow.jsp";
</script>
<%
}
} else {
%>
<script>
alert('用户不存在!');
window.location.href = "02borrow.jsp";
</script>
<%
String sql1 = "select * from borrow_card where ID =" + user; // SQL查询语句根据用户ID查询借阅卡信息
ResultSet rs1 = borrow.executeQuery(sql1); // 执行SQL查询返回结果集
if(session.getAttribute("manager")!=null){ // 检查会话中是否有管理员登录
if (rs1.next()) { // 如果查询到借阅卡信息
String rule = rs1.getString("rule_id"); // 获取借阅卡的规则ID
int cardstatus = Integer.parseInt(rs1.getString("STATUS")); // 获取借阅卡状态
String sql4="select*from rules where id = " + rule; // SQL查询语句根据规则ID查询规则信息
ResultSet rs4 = borrow.executeQuery(sql4); // 执行SQL查询返回结果集
int n = 0; // 初始化变量n
String library = ""; // 初始化图书馆字符串
String[] libraryArray = {}; // 初始化图书馆数组
int num = 0; // 初始化可借阅数量
while(rs4.next()){ // 遍历规则结果集
n = rs4.getInt("limit_day"); // 获取借阅天数限制
library = rs4.getString("borrow_library"); // 获取可借阅的图书馆
libraryArray = library.split("、"); // 将图书馆字符串分割成数组
num = rs4.getInt("borrow_num"); // 获取可借阅数量
}
}else{
%>
<script>
alert('请先登录!');
window.parent.location.href = "../loginManager.html";
</script>
<%
}
%>
EndTime endtime = new EndTime(); // 创建EndTime对象
String end = endtime.show(n); // 计算并获取借阅结束日期
if(cardstatus!=0){ // 如果借阅卡状态有效
String sql2 = "select * from books where ID =" + book; // SQL查询语句根据图书ID查询图书信息
ResultSet rs2 = borrow.executeQuery(sql2); // 执行SQL查询返回结果集
if (rs2.next()) { // 如果查询到图书信息
int status = Integer.parseInt(rs2.getString("STATUS")); // 获取图书状态
String lib = Integer.toString(rs2.getInt("library_id")); // 获取图书所在图书馆ID
for(int z=0;z<libraryArray.length;z++){ // 遍历图书馆数组
if(libraryArray[z].equals(lib)){ // 如果图书所在图书馆在可借阅范围内
String countSql = "select count(*) as count from borrow_books where manager_id is null and card_id =" + user; // SQL查询语句统计当前用户已借阅的图书数量
ResultSet rsSql = borrow.executeQuery(countSql); // 执行SQL查询返回结果集
int count = 0; // 初始化已借阅数量
while(rsSql.next()){ // 遍历结果集
count = rsSql.getInt("count"); // 获取已借阅数量
}
if(count<num){ // 如果已借阅数量小于可借阅数量
if(status==1){ // 如果图书状态为可借
String sql = "insert into borrow_books(CARD_ID,BOOK_ID,BORROW_DATE,END_DATE) values('" + user + "','" + book + "','" + date1 + "','" + end + "')"; // SQL插入语句插入借阅记录
int i = borrow.executeUpdate(sql); // 执行SQL插入操作返回受影响的行数
if (i == 1) { // 如果插入成功
try {
// 显示借阅成功消息并跳转页面
%>
('借阅成功!');
window.location.href = "02borrow.jsp";
<%
String sql3="update books set STATUS=0 where ID=" + book; // SQL更新语句更新图书状态为不可借
borrow.executeUpdate(sql3); // 执行SQL更新操作
<%
} catch (Exception e) { // 如果发生异常
// 显示借阅未成功消息并跳转页面
%>
('借阅未成功!');
window.location.href = "02borrow.jsp";
<%
}
} else { // 如果插入失败
// 显示借阅未成功消息并跳转页面
%>
('借阅未成功!');
window.location.href = "02borrow.jsp";
<%
}
}else{ // 如果图书状态不可借
// 显示图书已借出消息并跳转页面
%>
('该图书已借出!');
window.location.href = "02borrow.jsp";
<%
}
}else{ // 如果已借阅数量达到或超过可借阅数量
// 显示已达到借阅数量上限消息并跳转页面
%>
('该用户已达到可借阅数量上限!若需还书,请先借阅其他书籍!');
window.location.href = "02borrow.jsp";
<%
}
}if(z==libraryArray.length-1 && !libraryArray[z].equals(lib)){ // 如果遍历完所有图书馆且图书不在可借阅范围内
// 显示图书不在可借阅图书馆内消息并跳转页面
%>
('该图书未在可借阅的图书馆内!');
window.location.href = "02borrow.jsp";
<%
}
}
}else{ // 如果查询不到图书信息
// 显示图书不存在消息并跳转页面
%>
('该图书不存在!');
window.location.href = "02borrow.jsp";
<%
}
}else{ // 如果借阅卡状态无效
// 显示借阅卡已挂失消息并跳转页面
%>
('借阅卡已挂失!');
window.location.href = "02borrow.jsp";
<%
}
} else { // 如果查询不到借阅卡信息
// 显示用户不存在消息并跳转页面
%>
('用户不存在!');
window.location.href = "02borrow.jsp";
<%
}
}else{ // 如果会话中没有管理员登录
// 显示请先登录消息并跳转页面
%>
('请先登录!');
window.parent.location.href = "../loginManager.html";
<%
}
%>
</body>
</html>
</html>

@ -1,95 +1,96 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="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>
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
<script src="../public/layui/layui.js"></script>
<style>
.layui-form-label{
margin-left:20%;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
<style>
.layui-form-label{
margin-left:20%;
}
</style>
</head>
<body>
<div align="center" style=" margin-top: 2%;"><h1>查询图书是否逾期</h1></div>
<div align="center"
style="margin-left:30%; margin-top: 5%; width: 40%;">
<!-- 页面主体内容开始 -->
<div align="center" style=" margin-top: 2%;"><h1>查询图书是否逾期</h1></div>
<div align="center"
style="margin-left:30%; margin-top: 5%; width: 40%;">
<form class="layui-form layui-form-pane" action="04judgeSus.jsp">
<div class="layui-form-item">
<label class="layui-form-label">图书编号</label>
<div class="layui-input-inline">
<input type="text" name="bookid" lay-verify="required"
placeholder="请输入图书编号" autocomplete="off" class="layui-input"><br>
</div>
</div>
<!-- 表单开始action属性指定提交的URL -->
<form class="layui-form layui-form-pane" action="04judgeSus.jsp">
<div class="layui-form-item" align="center">
<button class="layui-btn layui-btn-warm" lay-submit="" lay-filter="demo2">查询</button>
<!-- 图书编号输入框 -->
<div class="layui-form-item">
<label class="layui-form-label">图书编号</label>
<div class="layui-input-inline">
<input type="text" name="bookid" lay-verify="required"
placeholder="请输入图书编号" autocomplete="off" class="layui-input"><br>
</div>
</form>
</div>
<!-- 提交按钮 -->
<div class="layui-form-item" align="center">
<button class="layui-btn layui-btn-warm" lay-submit="" lay-filter="demo2">查询</button>
</div>
</form>
<script>
layui
.use(
[ 'form', 'layedit', 'laydate' ],
function() {
var form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate;
//日期
laydate.render({
elem : '#date1',
type : 'datetime',
format : 'yyyy-M-d H:m:s',
min:0,
max:0,
value: new Date()
});
//创建一个编辑器
var editIndex = layedit
.build('LAY_demo_editor');
<!-- LayUI模块加载和初始化 -->
layui
.use(
[ 'form', 'layedit', 'laydate' ],
function() {
var form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate;
//日期选择器初始化
laydate.render({
elem : '#date1',
type : 'datetime',
format : 'yyyy-M-d H:m:s',
min:0,
max:0,
value: new Date()
});
//监听提交
form.on('submit(demo1)', function(data) {
layer.alert(JSON.stringify(data.field), {
title : '最终的提交信息'
})
return false;
});
//创建一个编辑器实例
var editIndex = layedit
.build('LAY_demo_editor');
//表单赋值
layui.$('#LAY-component-form-setval').on(
'click', function() {
form.val('example', {
"username" : "贤心" // "name": "value"
,
"password" : "123456",
"interest" : 1,
"like[write]" : true //复选框选中状态
,
"close" : true //开关状态
,
"sex" : "女",
"desc" : "我爱 layui"
});
});
//监听表单提交事件
form.on('submit(demo1)', function(data) {
layer.alert(JSON.stringify(data.field), {
title : '最终的提交信息'
});
return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
});
//表单取值
layui.$('#LAY-component-form-getval').on(
'click', function() {
var data = form.val('example');
alert(JSON.stringify(data));
});
//表单赋值示例
layui.$('#LAY-component-form-setval').on(
'click', function() {
form.val('example', {
"username" : "贤心" // "name": "value"
,
"password" : "123456",
"interest" : 1,
"like[write]" : true //复选框选中状态
,
"close" : true //开关状态
,
"sex" : "女",
"desc" : "我爱 layui"
});
});
});
</script>
</div>
//表单取值示例
layui.$('#LAY-component-form-getval').on(
'click', function() {
var data = form.val('example');
(JSON.stringify(data));
});
});
});
</script>
</div>
</body>
</html>
</html>

@ -1,80 +1,79 @@
<%@ page import="javabean.DateTime" %>
<%@ page import="javabean.CompareDate" %>
<%@ page import="java.sql.*" %>
<%@ page import="javabean.DateTime" %> // 导入自定义的DateTime类用于获取当前日期时间
<%@ page import="javabean.CompareDate" %> // 导入自定义的CompareDate类用于比较日期
<%@ page import="java.sql.*" %> // 导入Java SQL包用于数据库操作
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
pageEncoding="UTF-8"%> // 设置页面语言为Java内容类型和字符编码为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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="judge" scope="session" class="javabean.JDBCBean"></jsp:useBean>
<jsp:useBean id="judge" scope="session" class="javabean.JDBCBean"></jsp:useBean> // 使用JSP标签声明一个名为judge的会话范围的JavaBean对象类为javabean.JDBCBean
<%
String book = request.getParameter("bookid");
session.setAttribute("book", book);
if(session.getAttribute("manager")!=null){
DateTime date = new DateTime();
String now = date.show();
String bookid = request.getParameter("bookid");
String sql="select*from borrow_books where book_id = "+bookid;
ResultSet rs = judge.executeQuery(sql);
String end = "";
String ret = "";
String card = "";
while (rs.next()) {
end = rs.getString("end_date");
ret = rs.getString("return_date");
card = rs.getString("card_id");
}
if(ret==null){
//CompareDate cd = new CompareDate();
long n = CompareDate.show(now,end);
//out.println(sql);
//out.println(n);
//out.println(end);
//out.println(now);
session.setAttribute("days", n);
String sql1="select*from borrow_card where id = "+card;
ResultSet rs1 = judge.executeQuery(sql1);
String rule = "";
while (rs1.next()) {
rule = rs1.getString("rule_id");
}
String sql2="select*from rules where id = "+rule;
ResultSet rs2 = judge.executeQuery(sql2);
String fee = "";
while (rs2.next()) {
fee = rs2.getString("overtime_fee");
}
session.setAttribute("fee", fee);
%>
<script>
window.location.href = "04return.jsp";
</script>
<%
}else{
%>
<script>
alert("该书未借出或不存在!");
window.location.href = "04judge.jsp";
</script>
<%
String book = request.getParameter("bookid"); // 从请求中获取参数bookid的值
session.setAttribute("book", book); // 将bookid的值存储到会话属性中
if(session.getAttribute("manager")!=null){ // 检查会话中是否存在manager属性判断用户是否已登录
DateTime date = new DateTime(); // 创建DateTime对象实例
String now = date.show(); // 调用DateTime对象的show方法获取当前日期时间字符串
String bookid = request.getParameter("bookid"); // 再次从请求中获取参数bookid的值
String sql="select*from borrow_books where book_id = "+bookid; // 构建SQL查询语句查询借书记录表
ResultSet rs = judge.executeQuery(sql); // 执行SQL查询返回结果集
String end = ""; // 初始化变量end用于存储借书记录中的归还日期
String ret = ""; // 初始化变量ret用于存储借书记录中的归还日期
String card = ""; // 初始化变量card用于存储借书记录中的借书卡ID
while (rs.next()) { // 遍历结果集
end = rs.getString("end_date"); // 获取归还日期
ret = rs.getString("return_date"); // 获取实际归还日期
card = rs.getString("card_id"); // 获取借书卡ID
}
}else{
%>
<script>
alert('请先登录!');
window.parent.location.href = "../loginManager.html";
</script>
<%
if(ret==null){ // 如果实际归还日期为空,表示书未归还
//CompareDate cd = new CompareDate();
long n = CompareDate.show(now,end); // 计算当前日期与归还日期之间的天数差
//out.println(sql);
//out.println(n);
//out.println(end);
//out.println(now);
session.setAttribute("days", n); // 将天数差存储到会话属性中
String sql1="select*from borrow_card where id = "+card; // 构建SQL查询语句查询借书卡信息
ResultSet rs1 = judge.executeQuery(sql1); // 执行SQL查询返回结果集
String rule = ""; // 初始化变量rule用于存储规则ID
while (rs1.next()) { // 遍历结果集
rule = rs1.getString("rule_id"); // 获取规则ID
}
String sql2="select*from rules where id = "+rule; // 构建SQL查询语句查询规则信息
ResultSet rs2 = judge.executeQuery(sql2); // 执行SQL查询返回结果集
String fee = ""; // 初始化变量fee用于存储超时费用
while (rs2.next()) { // 遍历结果集
fee = rs2.getString("overtime_fee"); // 获取超时费用
}
session.setAttribute("fee", fee); // 将超时费用存储到会话属性中
%>
window.location.href = "04return.jsp"; // 跳转到04return.jsp页面
<%
}else{ // 如果实际归还日期不为空,表示书已归还或不存在
%>
("该书未借出或不存在!");
window.location.href = "04judge.jsp"; // 跳转到04judge.jsp页面
<%
}
}else{ // 如果会话中不存在manager属性表示用户未登录
%>
('请先登录!');
window.parent.location.href = "../loginManager.html"; // 跳转到登录页面
<%
}
%>
</body>
</html>
</html>

@ -1,168 +1,149 @@
<%@ page import="java.sql.*" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %> // 导入Java SQL包用于数据库操作
<jsp:useBean id="judge" scope="session" class="javabean.JDBCBean"></jsp:useBean> // 使用JSP的useBean标签来创建一个名为judge的JavaBean对象该对象在会话范围内有效
<!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>
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
<script src="../public/layui/layui.js"></script>
<style>
.layui-form-label{
margin-left:20%;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
<style>
.layui-form-label{
margin-left:20%;
}
</style>
</head>
<body>
<jsp:useBean id="judge" scope="session" class="javabean.JDBCBean"></jsp:useBean>
<div align="center" style=" margin-top: 2%;"><h1>归还图书</h1></div>
<div align="center"
style="margin-left:30%; margin-top: 5%; width: 40%;">
<div align="center" style=" margin-top: 2%; margin-left: 30%; width: 40%;">
<h1>归还图书</h1>
<form class="layui-form layui-form-pane" action="05returnSus.jsp">
<%
Object days = session.getAttribute("days");
Object fee = session.getAttribute("fee");
int d = Integer.parseInt(days.toString());
float f = Float.parseFloat(fee.toString());
String book = session.getAttribute("book").toString();
String mes = "";
String mes2 = "";
float sum = 0;
if(d<0){
mes = "已逾期"+(-d)+"天";
sum = d*f*(-1);
mes2 = "罚款"+sum;
}
else{
mes = "还剩"+d+"天";
//mes2 = "无需罚款";
}
session.setAttribute("mes",mes);
session.setAttribute("mes2",mes2);
%>
<form class="layui-form layui-form-pane" action="05returnSus.jsp">
<div><blockquote class="layui-elem-quote layui-quote-nm">
<%=session.getAttribute("mes") %><br>
<%=session.getAttribute("mes2") %>
</blockquote>
</div>
<div class="layui-form-item">
<label class="layui-form-label">图书编号</label>
<div class="layui-input-inline">
<input type="text" name="bookid" lay-verify="required"
value=<%=session.getAttribute("book") %> autocomplete="off" class="layui-input"><br>
</div>
Object days = session.getAttribute("days"); // 从会话中获取“days”属性
Object fee = session.getAttribute("fee"); // 从会话中获取“fee”属性
int d = Integer.parseInt(days.toString()); // 将“days”属性转换为整数
float f = Float.parseFloat(fee.toString()); // 将“fee”属性转换为浮点数
String book = session.getAttribute("book").toString(); // 从会话中获取“book”属性并转换为字符串
String mes = ""; // 初始化消息变量
String mes2 = ""; // 初始化消息变量
float sum = 0; // 初始化罚款总金额
if(d<0){ // 如果天数小于0表示逾期
mes = "已逾期"+(-d)+"天"; // 设置逾期消息
mes2 = "罚款"+sum+"元"; // 设置罚款消息
}else{ // 如果天数不小于0表示未逾期
mes = "还剩"+d+"天"; // 设置剩余天数消息
//mes2 = "无需罚款"; // 注释掉的代码,表示不需要罚款
}
session.setAttribute("mes", mes); // 将消息存储到会话中
session.setAttribute("mes2", mes2); // 将消息存储到会话中
%>
<div><blockquote class="layui-elem-quote layui-quote-nm">
<%=session.getAttribute("mes") %><br> // 显示会话中的逾期或剩余天数消息
<%=session.getAttribute("mes2") %> // 显示会话中的罚款消息
</blockquote></div>
<div class="layui-form-item">
<label class="layui-form-label">图书编号</label>
<div class="layui-input-inline">
<input type="text" name="bookid" lay-verify="required" value=<%=session.getAttribute("book") %> autocomplete="off" class="layui-input"><br> // 显示图书编号输入框
</div>
</div>
<%
String sql2="select*from borrow_books where return_date is null and book_id = "+book;
ResultSet rs2 = judge.executeQuery(sql2);
String end = "";
while (rs2.next()) {
%>
<%
String sql2="select*from borrow_books where return_date is null and book_id = "+book; // 查询未归还且图书ID匹配的借书记录
ResultSet rs2 = judge.executeQuery(sql2); // 执行查询并获取结果集
String end = ""; // 初始化截止日期变量
while(rs2.next()){ // 遍历结果集
%>
<div class="layui-form-item">
<label class="layui-form-label">截止日期</label>
<div class="layui-input-inline">
<input type="text" name="end" autocomplete="off" class="layui-input" value=<%=rs2.getString("end_date") %>><br> // 显示截止日期输入框
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">截止日期</label>
<div class="layui-input-inline">
<input type="text" name="end" autocomplete="off"
class="layui-input" value=<%=rs2.getString("end_date") %>><br>
</div>
<% } %>
<div class="layui-form-item">
<label class="layui-form-label">归还日期</label>
<div class="layui-input-inline">
<input type="text" name="date1" id="date1" autocomplete="off" class="layui-input"><br> // 显示归还日期输入框
</div>
<%} %>
<div class="layui-form-item">
<label class="layui-form-label">归还日期</label>
<div class="layui-input-inline">
<input type="text" name="date1" id="date1" autocomplete="off"
class="layui-input"><br>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">违规信息</label>
<div class="layui-input-inline">
<input type="text" name="ill" placeholder="若无违规信息,则不填" autocomplete="off" class="layui-input"><br> // 显示违规信息输入框
</div>
<div class="layui-form-item">
<label class="layui-form-label">违规信息</label>
<div class="layui-input-inline">
<input type="text" name="ill"
placeholder="若无违规信息,则不填" autocomplete="off" class="layui-input"><br>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">管理员编号</label>
<div class="layui-input-inline">
<input type="text" name="managerid" readonly="readonly"
class="layui-input" value="<%=session.getAttribute("manager")%>"><br>
</div>
</div>
<div class="layui-form-item" align="center">
<button class="layui-btn layui-btn-warm" lay-submit="" lay-filter="demo2">归还</button>
</div>
<div class="layui-form-item">
<label class="layui-form-label">管理员编号</label>
<div class="layui-input-inline">
<input type="text" name="manager" readonly="readonly" class="layui-input" value= <%=session.getAttribute("manager") %>> // 显示管理员编号输入框,只读
</div>
</form>
</div>
<div class="layui-form-item" align="center">
<button class="layui-btn layui-btn-warm" lay-submit="" lay-filter="demo1">归还</button> // 显示归还按钮
</div>
</form>
<script>
layui
.use(
[ 'form', 'layedit', 'laydate' ],
function() {
var form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate;
//日期
laydate.render({
elem : '#date1',
type : 'datetime',
format : 'yyyy-MM-dd H:m:s',
min:0,
max:0,
value: new Date()
});
//创建一个编辑器
var editIndex = layedit
.build('LAY_demo_editor');
</div>
//监听提交
form.on('submit(demo1)', function(data) {
layer.alert(JSON.stringify(data.field), {
title : '最终的提交信息'
})
return false;
});
<script>
layui.use(
[ 'form', 'layedit', 'laydate' ],
function() {
var form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate;
//日期
laydate.render({
elem : '#date1', // 绑定元素
type : 'datetime', // 类型:日期时间
format : 'yyyy-MM-dd H:m:s', // 格式
min:0, // 最小值
max:0, // 最大值
value: new Date() // 默认值:当前时间
});
//表单赋值
layui.$('#LAY-component-form-setval').on(
'click', function() {
form.val('example', {
"username" : "贤心" // "name": "value"
,
"password" : "123456",
"interest" : 1,
"like[write]" : true //复选框选中状态
,
"close" : true //开关状态
,
"sex" : "女",
"desc" : "我爱 layui"
});
});
//创建一个编辑器
var editIndex = layedit
.build('LAY_demo_editor');
//表单取值
layui.$('#LAY-component-form-getval').on(
'click', function() {
var data = form.val('example');
alert(JSON.stringify(data));
});
//监听提交
form.on('submit(demo1)', function(data) {
layer.alert(JSON.stringify(data.field), {
title : '最终的提交信息' // 弹窗标题
})
return false; // 阻止表单跳转。如果需要表单跳转,去掉这段即可。
});
//表单赋值
layui.$('#LAY-component-form-setval').on(
'click', function() {
form.val('example', {
"username" : "贤心" // "name": "value"
,
"password" : "123456",
"interest" : 1,
"like[write]" : true //复选框选中状态
,
"close" : true //开关状态
,
"sex" : "女",
"desc" : "我爱 layui"
});
</script>
});
//表单取值
layui.$('#LAY-component-form-getval').on(
'click', function() {
var data = form.val('example');
layer.alert(JSON.stringify(data)); // 弹出数据
});
});
</script>
</div>
</body>
</html>

@ -11,65 +11,66 @@
<jsp:useBean id="ret" scope="session" class="javabean.JDBCBean"></jsp:useBean>
<%
String book = request.getParameter("bookid");
String date1 = request.getParameter("date1");
String ill = request.getParameter("ill");
String book = request.getParameter("bookid");// 获取请求参数中的图书ID
String date1 = request.getParameter("date1"); // 获取请求参数中的归还日期
String ill = request.getParameter("ill"); // 获取请求参数中的是否违规信息
//out.println(ill);
String managerid = request.getParameter("managerid");
String managerid = request.getParameter("managerid"); // 获取请求参数中的管理员ID
if(session.getAttribute("manager")!=null){
if(session.getAttribute("manager")!=null){ // 检查用户是否已登录
String sql2 = "select * from books where ID =" + book;
ResultSet rs2 = ret.executeQuery(sql2);
if(rs2.next()){
//out.println(psw1 + " " + psw2);
//String id = session.getAttribute("manager").toString();
int status=Integer.parseInt(rs2.getString("STATUS"));
if(status==0){
String sql = "update borrow_books set RETURN_DATE='" + date1 + "',ILLEGAL='" + ill + "',MANAGER_ID='" + managerid + "' where manager_id is null and BOOK_ID="+ book;
//out.println(sql);
String sql2 = "select * from books where ID =" + book; // 查询图书信息的SQL语句
ResultSet rs2 = ret.executeQuery(sql2); // 执行查询并返回结果集
if(rs2.next()){ // 如果查询到图书信息
//out.println(psw1 + " " + psw2);
//String id = session.getAttribute("manager").toString();
int status=Integer.parseInt(rs2.getString("STATUS")); // 获取图书状态
if(status==0){ // 如果图书状态为未借出0
String sql = "update borrow_books set RETURN_DATE='" + date1 + "',ILLEGAL='" + ill + "',MANAGER_ID='" + managerid + "' where manager_id is null and BOOK_ID="+ book; // 更新借书记录的SQL语句
//out.println(sql);
try {
int i = ret.executeUpdate(sql);
int i = ret.executeUpdate(sql); // 执行更新操作,返回受影响的行数
//String sql1 = "update borrow_books set RETURN_DATE='" + date1 + "',ILLEGAL='" + ill + "',MANAGER_ID='" + managerid + "' order by BORROW_DATE desc limit 1 ";
//int k = ret.executeUpdate(sql1);
String sql3="update books set STATUS=1 where ID="+book;
ret.executeUpdate(sql3);
String sql3="update books set STATUS=1 where ID="+book;// SQL更新语句更新图书状态为已借出1
ret.executeUpdate(sql3);// 执行更新操作,返回受影响的行数
%>
<script>
alert('归还成功!');
window.location.href = "04judge.jsp";
alert('归还成功!');// 显示归还成功消息
window.location.href = "04judge.jsp";// 跳转到04judge.jsp页面
</script>
<%
} catch (Exception e) {
} catch (Exception e) { // 捕获异常
%>
<script>
alert('归还未成功!');
window.location.href = "04judge.jsp";
alert('归还未成功!');// 显示归还失败消息
window.location.href = "04judge.jsp";//跳转到04judge.jsp页面
</script>
<%
}
}else{
}else{ // 如果图书状态不为未借出0
%>
<script>
alert('该图书未借出!');
window.location.href = "04judge.jsp";
alert('该图书未借出!');// 显示图书未借出消息
window.location.href = "04judge.jsp";// 跳转到04judge.jsp页面
</script>
<%
}
}
}else{
}else{// 如果用户未登录
%>
<script>
alert('请先登录!');
window.parent.location.href = "../loginManager.html";
alert('请先登录!');// 显示请先登录消息
window.parent.location.href = "../loginManager.html";// 跳转到登录页面
</script>
<%
}

@ -1,5 +1,5 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
@ -11,110 +11,114 @@
margin: 0 0px;
}
</style>
</head>
<body>
<script src="../public/layui/layui.js" charset="utf-8"></script>
<!-- 表单 -->
<table class="layui-hide" id="cardTable" lay-filter="formFilter"></table>
<!-- 头部工具栏 -->
<script type="text/html" id="headBar">
条件搜索:
<div class="layui-inline">
<select id="condition" name="condition" lay-verify="required">
<option value=""></option>
<option value="card_id">借阅证号</option>
<option value="book_id">图书编号</option>
<option value="borrow_date">借阅日期</option>
<option value="end_date">截止日期</option>
<option value="return_date">归还日期</option>
<option value="illegal">违章信息</option>
<option value="manager_id">处理人</option>
</select>
</div>
<div class="layui-inline">
<input class="layui-input" id="conditionValue" name="conditionValue" id="demoReload" autocomplete="off">
</div>
<button class="layui-btn" name="condition" data-type="reload" lay-event="search">搜索</button>
</script>
<!-- 表单 -->
<table class="layui-hide" id="cardTable" lay-filter="formFilter"></table>
<!-- 头部工具栏 -->
条件搜索:
<div class="layui-inline">
<select id="condition" name="condition" lay-verify="required">
<option value=""></option>
<option value="card_id">借阅证号</option>
<option value="book_id">图书编号</option>
<option value="borrow_date">借阅日期</option>
<option value="end_date">截止日期</option>
<option value="return_date">归还日期</option>
<option value="illegal">违章信息</option>
<option value="manager_id">处理人</option>
</select>
</div>
<div class="layui-inline">
<input class="layui-input" id="conditionValue" name="conditionValue" id="demoReload" autocomplete="off">
</div>
<button class="layui-btn" name="condition" data-type="reload" lay-event="search">搜索</button>
</script>
<script>
<script>
layui.use(['table','jquery'], function(){
$ = layui.jquery;
var table = layui.table;
// 进行渲染
var tableIns = table.render({
elem: '#cardTable'
,url:'./borrowTable'
,toolbar: '#headBar'
,cols: [[
{field:'card_id', width:180, title: '借阅证号', sort: true}
,{field:'book_id', width:130, title: '图书编号', sort: true}
,{field:'borrow_date', width:250, title: '借阅日期', sort: true}
,{field:'end_date', title: '截止日期', width: 250, sort: true}
,{field:'return_date', width:250, title: '归还时间', sort: true}
,{field:'illegal', width:180, title: '违章信息', sort: true,style:'color: red;'}
,{field:'manager_id', minWidth:80, title: '处理人'}
$ = layui.jquery;
var table = layui.table;
// 进行渲染
var tableIns = table.render({
elem: '#cardTable'
,url:'./borrowTable'
,toolbar: '#headBar'
,cols: [[
{field:'card_id', width:180, title: '借阅证号', sort: true}
,{field:'book_id', width:130, title: '图书编号', sort: true}
,{field:'borrow_date', width:250, title: '借阅日期', sort: true}
,{field:'end_date', title: '截止日期', width: 250, sort: true}
,{field:'return_date', width:250, title: '归还时间', sort: true}
,{field:'illegal', width:180, title: '违章信息', sort: true,style:'color: red;'}
,{field:'manager_id', minWidth:80, title: '处理人'}
]]
,page: true
});
// 头部工具栏事件
table.on('toolbar(formFilter)', function(obj){
var checkStatus = table.checkStatus(obj.config.id);
switch(obj.event){
// 条件查找图书证
case 'search':
var conditionValue = $('#conditionValue');
var condition = $('#condition');
// 进行搜索,重新渲染
tableIns.reload({
where: { //设定异步数据接口的额外参数,任意设
"condition": condition.val(),
"conditionValue": conditionValue.val()
}
,page: {
curr: 1 //重新从第 1 页开始
}
});
break;
]]
,page: true
});
// 头部工具栏事件
table.on('toolbar(formFilter)', function(obj){
var checkStatus = table.checkStatus(obj.config.id);
switch(obj.event){
// 条件查找图书证
case 'search':
var conditionValue = $('#conditionValue');
var condition = $('#condition');
// 进行搜索,重新渲染
tableIns.reload({
where: { //设定异步数据接口的额外参数,任意设
"condition": condition.val(),
"conditionValue": conditionValue.val()
}
,page: {
curr: 1 //重新从第 1 页开始
}
});
break;
case 'add':
var addCardLayer = layer.open({
type: 2,
title: '添加借书证',
area: ['800px', '500px'],
maxmin: true,
shadeClose: true,
content: 'cardadd.jsp',
});
//layer.full(addCardLayer);
};
case 'add':
var addCardLayer = layer.open({
type: 2,
title: '添加借书证',
area: ['800px', '500px'],
maxmin: true,
shadeClose: true,
content: 'cardadd.jsp',
});
//layer.full(addCardLayer);
};
});
// 侧边工具栏事件
table.on(('tool(formFilter)'), function(obj){
var data = obj.data;
var layEvent = obj.event;
var tr = obj.tr;
switch(obj.event){
case 'edit':
layer.open({
type: 2,
title: '更改信息',
area: ['800px', '600px'],
maxmin: true,
shadeClose: true,
content: '',
})
break;
}
})
// 侧边工具栏事件
table.on(('tool(formFilter)'), function(obj){
var data = obj.data;
var layEvent = obj.event;
var tr = obj.tr;
switch(obj.event){
case 'edit':
layer.open({
type: 2,
title: '更改信息',
area: ['800px', '600px'],
maxmin: true,
shadeClose: true,
content: '',
})
break;
}
})
});
</script>
</script>
</body>
</html>
</html>

@ -1,114 +1,114 @@
<%@ 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">
pageEncoding="UTF-8"%> <!-- 设置页面语言为Java内容类型为HTML字符编码为UTF-8 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- 定义文档类型为HTML 4.01 Transitional -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
<script src="../public/layui/layui.js" charset="utf-8"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <!-- 设置页面的字符编码为UTF-8 -->
<title>Insert title here</title> <!-- 页面标题 -->
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all"> <!-- 引入Layui的CSS文件 -->
<style>
.layui-table,.layui-table-view{
margin: 0 0px;
margin: 0 0px; /* 设置表格和表格视图的外边距为0 */
}
</style>
</head>
<body>
<!-- 表单 -->
<table class="layui-hide" id="cardTable" lay-filter="formFilter"></table>
<!-- 头部工具栏 -->
<script type="text/html" id="headBar">
条件搜索:
<div class="layui-inline">
<select id="condition" name="condition" lay-verify="required">
<option value=""></option>
<option value="card_id">借阅证号</option>
<option value="book_id">图书编号</option>
<option value="borrow_date">借阅日期</option>
<option value="end_date">截止日期</option>
</select>
</div>
<div class="layui-inline">
<input class="layui-input" id="conditionValue" name="conditionValue" id="demoReload" autocomplete="off">
</div>
<button class="layui-btn" name="condition" data-type="reload" lay-event="search">搜索</button>
</script>
<!-- 表单 -->
<table class="layui-hide" id="cardTable" lay-filter="formFilter"></table> <!-- 创建一个隐藏的表格,用于展示数据 -->
<!-- 头部工具栏 -->
条件搜索: <!-- 条件搜索标签 -->
<div class="layui-inline">
<select id="condition" name="condition" lay-verify="required"> <!-- 下拉选择框,用于选择查询条件 -->
<option value=""></option> <!-- 空选项 -->
<option value="card_id">借阅证号</option> <!-- 借阅证号选项 -->
<option value="book_id">图书编号</option> <!-- 图书编号选项 -->
<option value="borrow_date">借阅日期</option> <!-- 借阅日期选项 -->
<option value="end_date">截止日期</option> <!-- 截止日期选项 -->
</select>
</div>
<div class="layui-inline">
<input class="layui-input" id="conditionValue" name="conditionValue" id="demoReload" autocomplete="off"> <!-- 输入框,用于输入查询条件的值 -->
</div>
<button class="layui-btn" name="condition" data-type="reload" lay-event="search">搜索</button> <!-- 搜索按钮 -->
</script>
<script>
layui.use(['table','jquery'], function(){
$ = layui.jquery;
var table = layui.table;
// 进行渲染
var tableIns = table.render({
elem: '#cardTable'
,url:'./returnTable'
,toolbar: '#headBar'
,cols: [[
{field:'card_id', width:180, title: '借阅证号', sort: true}
,{field:'book_id', width:130, title: '图书编号', sort: true}
,{field:'borrow_date', width:250, title: '借阅日期', sort: true}
,{field:'end_date', title: '截止日期',width: 250, sort: true}
]]
,page: true
});
// 头部工具栏事件
table.on('toolbar(formFilter)', function(obj){
var checkStatus = table.checkStatus(obj.config.id);
switch(obj.event){
// 条件查找图书证
case 'search':
var conditionValue = $('#conditionValue');
var condition = $('#condition');
// 进行搜索,重新渲染
tableIns.reload({
where: { //设定异步数据接口的额外参数,任意设
"condition": condition.val(),
"conditionValue": conditionValue.val()
}
,page: {
curr: 1 //重新从第 1 页开始
}
});
break;
case 'add':
var addCardLayer = layer.open({
type: 2,
title: '添加借书证',
area: ['800px', '500px'],
maxmin: true,
shadeClose: true,
content: 'cardadd.jsp',
});
//layer.full(addCardLayer);
};
<script>
layui.use(['table','jquery'], function(){ <!-- 使用Layui的table和jQuery模块 -->
$ = layui.jquery; <!-- 获取jQuery对象 -->
var table = layui.table; <!-- 获取table对象 -->
// 进行渲染
var tableIns = table.render({
elem: '#cardTable' <!-- 指定表格容器的ID -->
,url:'./returnTable' <!-- 数据接口地址 -->
,toolbar: '#headBar' <!-- 指定工具栏的ID -->
,cols: [[
{field:'card_id', width:180, title: '借阅证号', sort: true} <!-- 借阅证号列 -->
,{field:'book_id', width:130, title: '图书编号', sort: true} <!-- 图书编号列 -->
,{field:'borrow_date', width:250, title: '借阅日期', sort: true} <!-- 借阅日期列 -->
,{field:'end_date', title: '截止日期',width: 250, sort: true} <!-- 截止日期列 -->
]]
,page: true <!-- 启用分页 -->
});
// 侧边工具栏事件
table.on(('tool(formFilter)'), function(obj){
var data = obj.data;
var layEvent = obj.event;
var tr = obj.tr;
switch(obj.event){
case 'edit':
layer.open({
type: 2,
title: '更改信息',
area: ['800px', '600px'],
maxmin: true,
shadeClose: true,
content: '',
})
break;
}
})
// 头部工具栏事件
table.on('toolbar(formFilter)', function(obj){ <!-- 监听头部工具栏事件 -->
var checkStatus = table.checkStatus(obj.config.id); <!-- 获取选中状态 -->
switch(obj.event){
// 条件查找图书证
case 'search':
var conditionValue = $('#conditionValue'); <!-- 获取条件值输入框的值 -->
var condition = $('#condition'); <!-- 获取条件选择框的值 -->
// 进行搜索,重新渲染
tableIns.reload({
where: { //设定异步数据接口的额外参数,任意设
"condition": condition.val(), <!-- 设置查询条件 -->
"conditionValue": conditionValue.val() <!-- 设置查询条件的值 -->
}
,page: {
curr: 1 //重新从第 1 页开始
}
});
break;
case 'add':
var addCardLayer = layer.open({
type: 2,
title: '添加借书证',
area: ['800px', '500px'],
maxmin: true,
shadeClose: true,
content: 'cardadd.jsp',
});
//layer.full(addCardLayer);
};
});
// 侧边工具栏事件
table.on(('tool(formFilter)'), function(obj){ <!-- 监听侧边工具栏事件 -->
var data = obj.data; <!-- 获取当前行的数据 -->
var layEvent = obj.event; <!-- 获取触发的事件类型 -->
var tr = obj.tr; <!-- 获取当前行的DOM对象 -->
switch(obj.event){
case 'edit':
layer.open({
type: 2,
title: '更改信息',
area: ['800px', '600px'],
maxmin: true,
shadeClose: true,
content: '',
})
break;
}
})
});
</script>
</script>
</body>
</html>

@ -1,69 +1,64 @@
<%@ 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">
pageEncoding="UTF-8"%> <!-- 设置页面语言为Java内容类型为HTML字符编码为UTF-8 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- 定义文档类型为HTML 4.01 Transitional -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../public/layui/css/layui.css">
<script src="../public/layui/layui.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <!-- 设置页面内容类型和字符编码 -->
<title>Insert title here</title> <!-- 页面标题 -->
<link rel="stylesheet" href="../public/layui/css/layui.css"> <!-- 引入Layui的CSS样式文件 -->
</head>
<body>
<form class="layui-form layui-form-pane" action="" lay-filter="formFilter">
<div class="layui-form-item">
<label class="layui-form-label">标题</label>
<div class="layui-input-block">
<input type="text" name="title" lay-verify="required" required autocomplete="off" placeholder="请输入标题" class="layui-input">
<form class="layui-form layui-form-pane" action="" lay-filter="formFilter"> <!-- 创建一个表单使用Layui的表单类和过滤器 -->
<div class="layui-form-item"> <!-- 表单项开始 -->
<label class="layui-form-label">标题</label> <!-- 标签显示“标题” -->
<div class="layui-input-block"> <!-- 输入块开始 -->
<input type="text" name="title" lay-verify="required" required autocomplete="off" placeholder="请输入标题" class="layui-input"> <!-- 文本输入框,必填,自动完成关闭,占位符为“请输入标题” -->
</div>
</div>
<div class="layui-form-item" style="height:50%;">
<label class="layui-form-label">公告</label>
<div class="layui-input-block">
<textarea name="detail" lay-verify="required" placeholder="请输入公告" autocomplete="off" class="layui-input" style="height:300px;"></textarea>
<div class="layui-form-item" style="height:50%;"> <!-- 表单项开始高度为50% -->
<label class="layui-form-label">公告</label> <!-- 标签显示“公告” -->
<div class="layui-input-block"> <!-- 输入块开始 -->
<textarea name="detail" lay-verify="required" placeholder="请输入公告" autocomplete="off" class="layui-input" style="height:300px;"></textarea> <!-- 多行文本输入框必填自动完成关闭占位符为“请输入公告”高度为300px -->
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button type="submit" class="layui-btn" lay-submit="" lay-filter="submitButton"><i class="layui-icon layui-icon-release" style="font-size: 20px; color: yellow;"></i>&nbsp;发布</button>
<div class="layui-form-item"> <!-- 表单项开始 -->
<div class="layui-input-block"> <!-- 输入块开始 -->
<button type="submit" class="layui-btn" lay-submit="" lay-filter="submitButton"><i class="layui-icon layui-icon-release" style="font-size: 20px; color: yellow;"></i>&nbsp;发布</button> <!-- 提交按钮使用Layui的按钮类和图标类点击后触发提交事件 -->
</div>
</div>
</form>
<script>
layui.use(['form', 'jquery'], function(){ // 使用Layui的form和jQuery模块
$ = layui.jquery; // 获取jQuery对象
var form = layui.form // 获取form对象
,layer = layui.layer // 获取layer对象
//监听提交
form.on('submit(submitButton)', function(data){ // 监听表单提交事件
$.ajax({ // 发起Ajax请求
url: './announcementAdd', // 请求URL
method: 'post', // 请求方法为POST
data: data.field, // 请求数据为表单数据
dataType: 'json', // 期望服务器返回的数据类型为JSON
success: function(data){ // 请求成功时的回调函数
if(data.code == "0"){ // 如果返回码为0表示成功
parent.layer.msg("添加成功",{ // 弹出提示信息“添加成功”
icon: 6, // 图标类型为笑脸
time: 500 // 显示时间为500毫秒
});
setTimeout(function(){ // 设置延时操作
parent.location.reload(); // 刷新父页面
}, 500); // 延时500毫秒后执行
}else{ // 如果返回码不为0表示失败
layer.msg(data.msg); // 弹出错误信息
}
}
})
layui.use(['form', 'jquery'], function(){
$ = layui.jquery;
var form = layui.form
,layer = layui.layer
//监听提交
form.on('submit(submitButton)', function(data){
$.ajax({
url: './announcementAdd',
method: 'post',
data: data.field,
dataType: 'json',
success: function(data){
if(data.code == "0"){
parent.layer.msg("添加成功",{
icon: 6,
time: 500
});
setTimeout(function(){
parent.location.reload();
}, 500);
}else{
layer.msg(data.msg);
}
}
})
return false;
});
});
return false; // 阻止表单默认提交行为
});
});
</script>
</body>
</html>
</html>

@ -1,109 +1,111 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="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">
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
<script src="../public/layui/layui.js"></script>
<title>Insert title here</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- 引入layui的CSS文件 -->
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
<title>Insert title here</title>
</head>
<body>
<table class="layui-hide" id="annTable" lay-filter="formFilter"></table>
<script type="text/html" id="headBar">
<button type="button" class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon"><i class="layui-icon layui-icon-release" style="font-size: 20px; color: yellow;"></i>&nbsp;发布新公告</i></button>
<!-- 定义一个隐藏的表格,用于展示公告信息 -->
<table class="layui-hide" id="annTable" lay-filter="formFilter"></table>
<!-- 添加公告按钮 -->
<button type="button" class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon"><i class="layui-icon layui-icon-release" style="font-size: 20px; color: yellow;"></i>&nbsp;发布新公告</i></button>
<!-- 编辑和删除按钮 -->
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/html" id="rightBar">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>
layui.use(['table','jquery'], function(){
$ = layui.jquery;
var table = layui.table;
// 进行渲染
var tableIns = table.render({
elem: '#annTable'
,url:'./announcement'
,toolbar: '#headBar'
,height: 600
,cols: [[
{field:'id', width:80, title: 'ID', sort: true}
,{field:'title', width:230, title: '标题'}
,{field:'detail', width:580, title: '公告'}
,{field:'publish_date', title: '发布日期', minWidth: 100, sort: true}
,{fixed: 'right', title:'操作', toolbar: '#rightBar', align: 'center', width:150}
]]
});
// 头部工具栏事件
table.on('toolbar(formFilter)', function(obj){
var checkStatus = table.checkStatus(obj.config.id);
switch(obj.event){
// 添加公告
case 'add':
var addCardLayer = layer.open({
type: 2,
title: '发布公告',
area: ['800px', '500px'],
maxmin: true,
shadeClose: true,
content: '08add.jsp',
});
//layer.full(addCardLayer);
};
<script>
<!-- 使用layui的模块 -->
layui.use(['table','jquery'], function(){
$ = layui.jquery; // 获取jQuery对象
var table = layui.table; // 获取table模块
// 进行渲染
var tableIns = table.render({
elem: '#annTable' // 绑定到页面中的表格元素
,url:'./announcement' // 数据接口地址
,toolbar: '#headBar' // 工具栏模板选择器
,height: 600 // 设置表格高度
,cols: [[ // 定义表格列
{field:'id', width:80, title: 'ID', sort: true} // ID列
,{field:'title', width:230, title: '标题'} // 标题列
,{field:'detail', width:580, title: '公告'} // 公告内容列
,{field:'publish_date', title: '发布日期', minWidth: 100, sort: true} // 发布日期列
,{fixed: 'right', title:'操作', toolbar: '#rightBar', align: 'center', width:150} // 操作列
]]
});
// 头部工具栏事件
table.on('toolbar(formFilter)', function(obj){
var checkStatus = table.checkStatus(obj.config.id); // 获取选中状态
switch(obj.event){
// 添加公告
case 'add':
var addCardLayer = layer.open({
type: 2, // iframe层
title: '发布公告', // 标题
area: ['800px', '500px'], // 宽高
maxmin: true, // 允许最大化最小化
shadeClose: true, // 点击遮罩关闭
content: '08add.jsp', // iframe的URL
});
//layer.full(addCardLayer);
};
});
// 侧边工具栏事件
table.on(('tool(formFilter)'), function(obj){
var data = obj.data; // 获取当前行的数据
var layEvent = obj.event; // 获取触发的事件类型
var id = data.id; // 获取当前行的ID
var tr = obj.tr; // 获取当前行的DOM对象
switch(obj.event){
case 'edit':
layer.open({
type: 2, // iframe层
title: '更改信息', // 标题
area: ['800px', '600px'], // 宽高
maxmin: true, // 允许最大化最小化
shadeClose: true, // 点击遮罩关闭
content: '08edit.jsp?id=' +id, // URL传递参数ID
})
break;
case 'del':
layer.confirm('确定要删除么?',function(){ // 确认对话框
layer.msg("ok"); // 提示消息
$.ajax({
url: './announcementDel', // URL地址
data: 'id=' +id, // 传递参数ID
type: 'get', // HTTP请求类型
dataType: 'json', // 返回数据类型
timeout: 3000, // 超时时间
success: function(data){ // 成功回调函数
if(data.code == 0){ // 如果返回码为0
layer.msg(data.msg,{ // 显示成功消息
icon: 6, // icon样式
anim: 5, // 动画效果
time: 500 // 显示时间
});
setTimeout(function(){ // 延时刷新父页面
parent.location.reload();
},500);
}else{ // 如果返回码不为0
layer.msg(data.code); // 显示错误消息
}
},
error: function(){ // 失败回调函数
layer.msg("连接超时"); // 显示超时消息
}
})
})
}
})
});
// 侧边工具栏事件
table.on(('tool(formFilter)'), function(obj){
var data = obj.data;
var layEvent = obj.event;
var id = data.id;
var tr = obj.tr;
switch(obj.event){
case 'edit':
layer.open({
type: 2,
title: '更改信息',
area: ['800px', '600px'],
maxmin: true,
shadeClose: true,
content: '08edit.jsp?id=' +id,
})
break;
case 'del':
layer.confirm('确定要删除么?',function(){
layer.msg("ok");
$.ajax({
url: './announcementDel',
data: 'id=' +id,
type: 'get',
dataType: 'json',
timeout: 3000,
success: function(data){
if(data.code == 0){
layer.msg(data.msg,{
icon: 6,
anim: 5,
time: 500
});
setTimeout(function(){
parent.location.reload();
},500);
}else{
layer.msg(data.code);
}
},
error: function(){
layer.msg("连接超时");
}
})
})
}
})
});
</script>
</body>
</html>

@ -1,82 +1,80 @@
<%@page import="java.sql.*"%>
<%@page import="javabean.Base"%>
<%@page import="java.sql.*"%> <!-- 导入Java SQL包 -->
<%@page import="javabean.Base"%> <!-- 导入自定义的Base类 -->
<%@ 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">
pageEncoding="UTF-8"%> <!-- 设置页面语言为Java内容类型和字符编码为UTF-8 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- 定义文档类型为HTML 4.01 Transitional -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../public/layui/css/layui.css">
<script src="../public/layui/layui.js"></script>
<title>Insert title here</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <!-- 设置内容类型和字符编码为UTF-8 -->
<link rel="stylesheet" href="../public/layui/css/layui.css"> <!-- 引入Layui样式表 -->
<title>Insert title here</title> <!-- 页面标题 -->
</head>
<body>
<jsp:useBean id="check" scope="session" class="javabean.JDBCBean"></jsp:useBean>
<jsp:useBean id="check" scope="session" class="javabean.JDBCBean"></jsp:useBean> <!-- 使用JSP标签声明一个名为check的JavaBean作用域为session类为javabean.JDBCBean -->
<%
String id = request.getParameter("id");
Connection connection = (Connection)Base.getConnection();
String sql = "select * from announcement where id=?";
PreparedStatement pstmt = connection.prepareCall(sql);
pstmt.setString(1,id);
ResultSet resultSet = pstmt.executeQuery();
resultSet.next();
String id = request.getParameter("id");
Connection connection = (Connection)Base.getConnection();
String sql = "select * from announcement where id=?";
PreparedStatement pstmt = connection.prepareCall(sql);
pstmt.setString(1,id);
ResultSet resultSet = pstmt.executeQuery();
resultSet.next();
%>
<form class="layui-form layui-form-pane" action="" lay-filter="formFilter">
<input type="text" name="id" value=<%=id %> lay-verify="required" required autocomplete="off" placeholder="请输入姓名" class="layui-input layui-hide">
<div class="layui-form-item">
<label class="layui-form-label">标题</label>
<div class="layui-input-block">
<input type="text" name="title" value=<%=resultSet.getString("title") %> lay-verify="required" required autocomplete="off" placeholder="请输入标题" class="layui-input">
<form class="layui-form layui-form-pane" action="" lay-filter="formFilter"> <!-- 创建一个表单action属性为空lay-filter属性为formFilter -->
<input type="text" name="id" value=<%=id %> lay-verify="required" required autocomplete="off" placeholder="请输入姓名" class="layui-input layui-hide"> <!-- 隐藏的输入框用于存储公告的id -->
<div class="layui-form-item">
<label class="layui-form-label">标题</label> <!-- 标题标签 -->
<div class="layui-input-block">
<input type="text" name="title" value=<%=resultSet.getString("title") %> lay-verify="required" required autocomplete="off" placeholder="请输入标题" class="layui-input"> <!-- 输入框,用于编辑公告标题 -->
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">公告</label>
<div class="layui-input-block">
<input type="text" name="detail" value=<%=resultSet.getString("detail") %> lay-verify="required" placeholder="请输入公告" autocomplete="off" class="layui-input">
<label class="layui-form-label">公告</label> <!-- 公告标签 -->
<div class="layui-input-block">
<input type="text" name="detail" value=<%=resultSet.getString("detail") %> lay-verify="required" placeholder="请输入公告" autocomplete="off" class="layui-input"> <!-- 输入框,用于编辑公告内容 -->
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button type="submit" class="layui-btn" lay-submit="" lay-filter="submitButton">立即提交</button>
<div class="layui-form-item">
<div class="layui-input-block">
<button type="submit" class="layui-btn" lay-submit="" lay-filter="submitButton">立即提交</button> <!-- 提交按钮,触发表单提交事件 -->
</div>
</div>
</div>
</form>
<script>
layui.use(['form', 'jquery'], function(){
$ = layui.jquery;
var form = layui.form
,layer = layui.layer
//监听提交
form.on('submit(submitButton)', function(data){
$.ajax({
url: './announcementEdit',
method: 'post',
data: data.field,
dataType: 'json',
success: function(data){
if(data.code == "0"){
parent.layer.msg("添加成功",{
icon: 6,
time: 500
});
setTimeout(function(){
parent.location.reload();
}, 500);
}else{
layer.msg(data.msg);
}
}
})
return false;
});
});
layui.use(['form', 'jquery'], function(){ <!-- 使用Layui的form和jQuery模块 -->
$ = layui.jquery; <!-- 将jQuery赋值给$变量 -->
var form = layui.form <!-- 获取form模块 -->
,layer = layui.layer <!-- 获取layer模块 -->
//监听提交
form.on('submit(submitButton)', function(data){ <!-- 监听表单提交事件 -->
$.ajax({
url: './announcementEdit', <!-- AJAX请求的URL -->
method: 'post', <!-- HTTP请求方法为POST -->
data: data.field, <!-- 发送的数据为表单数据 -->
dataType: 'json', <!-- 期望服务器返回的数据类型为JSON -->
success: function(data){ <!-- AJAX请求成功时的回调函数 -->
if(data.code == "0"){ <!-- 如果返回的code为0表示操作成功 -->
parent.layer.msg("添加成功",{ <!-- 显示成功消息 -->
icon: 6, <!-- 消息图标类型 -->
time: 500 <!-- 消息显示时间 -->
});
setTimeout(function(){ <!-- 延迟500毫秒后刷新父页面 -->
parent.location.reload();
}, 500);
}else{
layer.msg(data.msg); <!-- 如果操作失败,显示错误消息 -->
}
}
})
return false; <!-- 阻止表单默认提交行为 -->
});
});
</script>
</body>

@ -1,194 +1,154 @@
<%@ page import="java.sql.*" %>
<%@ 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">
<%@ page import="java.sql.*" %> <!-- 导入Java SQL包 -->
<%@ 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>
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
<script src="../public/layui/layui.js"></script>
<!-- Bootstrap -->
<link href="../css/bootstrap.min.css" rel="stylesheet">
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery所以必须放在前边) -->
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="../public/css/default.css" />
<link rel="stylesheet" type="text/css"
href="../public/css/component.css" />
<script src="../public/js/modernizr.custom.js"></script>
<style>
body{
background-color:white !important;
color:black !important;
}
.md-content {
color: black;
background: white;
position: relative;
border-radius: 3px;
margin: 0 auto;
}
button{
background-color:#009688;
}
button:hover{
background-color:#5FB878;
}
.md-modal{
width: 35%;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <!-- 设置内容类型和字符编码 -->
<title>Insert title here</title> <!-- 页面标题 -->
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all"> <!-- 引入Layui样式表 -->
<!-- Bootstrap -->
<link href="../css/bootstrap.min.css" rel="stylesheet"> <!-- 引入Bootstrap样式表 -->
<link rel="stylesheet" type="text/css" href="../public/css/default.css" /> <!-- 引入默认样式表 -->
<link rel="stylesheet" type="text/css" href="../public/css/component.css" /> <!-- 引入组件样式表 -->
<script src="../js/jquery-3.2.1.min.js"></script> <!-- 引入jQuery库 -->
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery所以必须放在前边) -->
<link rel="stylesheet" href="https://cdn.bootcss.com/twitter-bootstrap/4.3.1/css/bootstrap.min.css"> <!-- 引入Bootstrap样式表 -->
<style>
body{background-color:white !important; color:black !important;} <!-- 设置页面背景色和文字颜色 -->
.md-content { color: black; background: white; position: relative; border-radius: 3px; margin: 0 auto;} <!-- 设置模态框内容样式 -->
button{background-color:#009688;} <!-- 设置按钮背景色 -->
button:hover{background-color:#5FB878;} <!-- 设置按钮悬停时的背景色 -->
.md-modal{ width:35%;} <!-- 设置模态框宽度 -->
</style>
</head>
<body>
<jsp:useBean id="gly" scope="session" class="javabean.JDBCBean"></jsp:useBean>
<fieldset class="layui-elem-field" style="width:30%;margin-left:30%;margin-top:5%;height:30%;">
<legend>管理员基本信息</legend>
<div class="layui-field-box" align="center" style="font-size:20px;font-family:YouYuan;margin-top:10%;margin-bottom:10%;">
<%
String manacc = session.getAttribute("manager").toString();
String sql = "select*from manager where ACCOUNT = '"+ manacc +"';";
//out.print(sql);
ResultSet rs = gly.executeQuery(sql);
while(rs.next()){
%>
<p>姓名:<%=rs.getString("name") %></p><br>
<p>账号:<%=rs.getString("account") %></p><br>
<p>邮箱:<%=rs.getString("email") %></p><br>
<button class="md-trigger layui-btn layui-btn-radius" data-modal="modal-3">修改名字</button>
<button class="md-trigger layui-btn layui-btn-radius" data-modal="modal-13">修改密码</button>
<button class="md-trigger layui-btn layui-btn-radius" data-modal="modal-1">修改邮箱</button>
<%
}
%>
</div>
</fieldset>
<div class="md-modal md-effect-13" id="modal-13">
<div class="md-content">
<h3>修改密码</h3>
<form action="10updateManager.jsp" method="post"
class="form-horizontal">
<div class="form-group" align="center" style="margin-left:3%;">
<br>
<label for="psw1" class="col-sm-2 control-label" >新密码</label>
<div class="col-sm-10" align="center">
<input type="password" class="form-control" name="psw1" id="password1" placeholder="请输入新密码" style="width:50%;margin-left:8%;"/>
</div>
</div>
<jsp:useBean id="gly" scope="session" class="javabean.JDBCBean"></jsp:useBean> <!-- 使用JavaBean -->
<fieldset class="layui-elem-field" style="width:30%;margin-left:30%;margin-top:5%;height:20%;">
<legend>管理员基本信息</legend>
<div class="layui-field-box" align="center" style="font-size:20px;font-family:YouYuan;">
<%
String manacc = session.getAttribute("manager").toString(); // 获取当前登录的管理员账号
String sql = "select* from manager where ACCOUNT = '"+manacc+"'"; // 查询管理员信息的SQL语句
ResultSet rs = gly.executeQuery(sql); // 执行查询并获取结果集
while(rs.next()){ // 遍历结果集
%>
<p>姓名:<%=rs.getString("name") %></p> <!-- 显示管理员姓名 -->
<p>账号:<%=rs.getString("account") %></p> <!-- 显示管理员账号 -->
<p>邮箱:<%=rs.getString("email") %></p> <!-- 显示管理员邮箱 -->
<button class="md-trigger layui-btn layui-btn-radius" data-modal="modal-3">修改名字</button> <!-- 修改名字按钮 -->
<button class="md-trigger layui-btn layui-btn-radius" data-modal="modal-13">修改密码</button> <!-- 修改密码按钮 -->
<button class="md-trigger layui-btn layui-btn-radius" data-modal="modal-1">修改邮箱</button> <!-- 修改邮箱按钮 -->
<%
}
%>
</div>
</fieldset> <!-- 结束fieldset标签 -->
<div class="md-modal md-effect-13" id="modal-13"> <!-- 修改密码模态框 -->
<div class="md-content">
<h3>修改密码</h3>
<form action="10updateManager.jsp" method="post" class="form-horizontal">
<div class="form-group" align="center" style="margin-left:3%;">
<br>
<div class="form-group" align="center" style="margin-left:3%;">
<label for="psw2" class="col-sm-2 control-label">新密码</label>
<div class="col-sm-10">
<input type="password" class="form-control" name="psw2" id="password2" placeholder="请再次输入密码进行确认" style="width:50%;margin-left:8%;"/>
</div>
<label for="psw1" class="col-sm-2 control-label" >新密码</label>
<div class="col-sm-10" align="center">
<input type="password" class="form-control" name="psw1" id="password1" placeholder="请输入新密码" style="width:50%;margin-left:8%;"/>
</div>
<div align="center">
<input type="submit" class="layui-btn layui-btn-radius" value="确认">
</div>
<br>
<div class="form-group" align="center" style="margin-left:3%;">
<label for="psw2" class="col-sm-2 control-label">新密码</label>
<div class="col-sm-10">
<input type="password" class="form-control" name="psw2" id="password2" placeholder="请再次输入密码进行确认" style="width:50%;margin-left:8%;"/>
</div>
<br>
</form>
<button class="md-close layui-btn-radius" style="font-size:14px;">取消</button>
<br>
</div>
</div>
<div align="center">
<input type="submit" class="layui-btn layui-btn-radius" value="确认"/>
</div>
<br>
</form>
<button class="md-close layui-btn-radius" style="font-size:14px;">取消</button>
<br>
</div>
</div>
<div class="md-modal md-effect-13" id="modal-1">
<div class="md-content">
<h3>修改邮箱</h3>
<form action="10updateManager.jsp" method="post"
class="form-horizontal">
<div class="form-group" align="center" style="margin-left:3%;">
<br>
<label for="email1" class="col-sm-2 control-label" >新邮箱</label>
<div class="col-sm-10" align="center">
<input type="text" class="form-control" name="email1" id="password1" placeholder="请输入新邮箱" style="width:50%;margin-left:8%;"/>
</div>
</div>
<div class="md-modal md-effect-13" id="modal-1"> <!-- 修改邮箱模态框 -->
<div class="md-content">
<h3>修改邮箱</h3>
<form action="10updateManager.jsp" method="post" class="form-horizontal">
<div class="form-group" align="center" style="margin-left:3%;">
<br>
<div class="form-group" align="center" style="margin-left:3%;">
<label for="email2" class="col-sm-2 control-label">新邮箱</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="email2" id="password2" placeholder="请再次输入邮箱进行确认" style="width:50%;margin-left:8%;"/>
</div>
<label for="email1" class="col-sm-2 control-label" >新邮箱</label>
<div class="col-sm-10" align="center">
<input type="text" class="form-control" name="email1" id="password1" placeholder="请输入新邮箱" style="width:50%;margin-left:8%;"/>
</div>
<div align="center">
<input type="submit" class="layui-btn layui-btn-radius" value="确认">
</div>
<br>
<div class="form-group" align="center" style="margin-left:3%;">
<label for="email2" class="col-sm-2 control-label">新邮箱</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="email2" id="password2" placeholder="请再次输入邮箱进行确认" style="width:50%;margin-left:8%;"/>
</div>
<br>
</form>
<button class="md-close layui-btn-radius" style="font-size:14px;">取消</button>
<br>
</div>
</div>
<div align="center">
<input type="submit" class="layui-btn layui-btn-radius" value="确认"/>
</div>
<br>
</form>
<button class="md-close layui-btn-radius" style="font-size:14px;">取消</button>
<br>
</div>
</div>
<div class="md-modal md-effect-13" id="modal-3">
<div class="md-content">
<h3>修改名字</h3>
<form action="10updateManager.jsp" method="post"
class="form-horizontal">
<div class="form-group" align="center" style="margin-left:3%;">
<br>
<label for="name1" class="col-sm-2 control-label" >新名字</label>
<div class="col-sm-10" align="center">
<input type="text" class="form-control" name="name1" id="password1" placeholder="请输入新名字" style="width:50%;margin-left:8%;"/>
</div>
</div>
<div class="md-modal md-effect-13" id="modal-3"> <!-- 修改名字模态框 -->
<div class="md-content">
<h3>修改名字</h3>
<form action="10updateManager.jsp" method="post" class="form-horizontal">
<div class="form-group" align="center" style="margin-left:3%;">
<br>
<div class="form-group" align="center" style="margin-left:3%;">
<label for="name2" class="col-sm-2 control-label">新名字</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="name2" id="password2" placeholder="请再次输入名字进行确认" style="width:50%;margin-left:8%;"/>
</div>
<label for="name1" class="col-sm-2 control-label" >新名字</label>
<div class="col-sm-10" align="center">
<input type="text" class="form-control" name="name1" id="password1" placeholder="请输入新名字" style="width:50%;margin-left:8%;"/>
</div>
<div align="center">
<input type="submit" class="layui-btn layui-btn-radius" value="确认">
</div>
<br>
<div class="form-group" align="center" style="margin-left:3%;">
<label for="name2" class="col-sm-2 control-label">新名字</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="name2" id="password2" placeholder="请再次输入名字进行确认" style="width:50%;margin-left:8%;"/>
</div>
<br>
</form>
<button class="md-close layui-btn-radius" style="font-size:14px;">取消</button>
<br>
</div>
</div>
<div align="center">
<input type="submit" class="layui-btn layui-btn-radius" value="确认"/>
</div>
<br>
</form>
<button class="md-close layui-btn-radius" style="font-size:14px;">取消</button>
<br>
</div>
<div class="md-overlay"></div>
<!-- the overlay element -->
<!-- classie.js by @desandro: https://github.com/desandro/classie -->
<script src="../public/js/classie.js"></script>
<script src="../public/js/modalEffects.js"></script>
<!-- for the blur effect -->
<!-- by @derSchepp https://github.com/Schepp/CSS-Filters-Polyfill -->
<script>
// this is important for IEs
var polyfilter_scriptpath = '/js/';
</script>
<script src="../public/js/cssParser.js"></script>
<script src="../public/js/css-filters-polyfill.js"></script>
</div>
<div class="md-overlay"></div> <!-- 模态框的遮罩层 -->
<!-- for the blur effect -->
<!-- by SDE @ desandro -->
<!-- IE is important for this -->
<!-- this script is required for the blur effect -->
<!-- you can also use CSS filters but they are not as good -->
<script src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="/js/polyfiller.js"></script> <!-- polyfill脚本路径 -->
</body>
</html>

@ -1,52 +1,52 @@
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%> <!-- 导入Java SQL包 -->
<%@ page import="java.util.*"%> <!-- 导入Java Util包 -->
<%@ 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">
pageEncoding="UTF-8"%> <!-- 设置页面语言为Java内容类型为HTML字符编码为UTF-8 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- 定义文档类型为HTML 4.01 Transitional -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <!-- 设置内容类型和字符编码 -->
<title>Insert title here</title> <!-- 页面标题 -->
</head>
<body>
<jsp:useBean id="check" scope="session" class="javabean.JDBCBean"></jsp:useBean>
<jsp:useBean id="check" scope="session" class="javabean.JDBCBean"></jsp:useBean> <!-- 使用JSP beanID为check作用域为session类为javabean.JDBCBean -->
<%
String psw1 = request.getParameter("psw1");
String psw2 = request.getParameter("psw2");
String email1 = request.getParameter("email1");
String email2 = request.getParameter("email2");
String name1 = request.getParameter("name1");
String name2 = request.getParameter("name2");
//out.println(psw1 + " " + psw2);
String id = session.getAttribute("manager").toString();
if(psw1!=null && psw2!=null){
String psw1 = request.getParameter("psw1"); //获取请求参数psw1
String psw2 = request.getParameter("psw2"); //获取请求参数psw2
String email1 = request.getParameter("email1");//获取请求参数email1
String email2 = request.getParameter("email2"); //获取请求参数email2
String name1 = request.getParameter("name1"); //获取请求参数name1
String name2 = request.getParameter("name2"); //获取请求参数name2
//out.println(psw1 + " " + psw2); <!-- 输出psw1和psw2的值已注释 -->
String id = session.getAttribute("manager").toString(); //从session中获取manager属性并转换为字符串
if(psw1!=null && psw2!=null){ //如果psw1和psw2不为空
if (psw1.equals(psw2) && psw1 != null && psw2 != null && !psw1.trim().equals("")
&& !psw2.trim().equals("")) {
String sql = "update manager set PASSWORD ='" + psw1 + "' where ACCOUNT='" + id +"'";
try {
int i = check.executeUpdate(sql);
if (i == 1) {
&& !psw2.trim().equals("")) { //如果psw1等于psw2且都不为空且不全是空格
String sql = "update manager set PASSWORD ='" + psw1 + "' where ACCOUNT='" + id +"'"; //构建SQL更新语句
try {
int i = check.executeUpdate(sql); //执行SQL更新语句
if (i == 1) { //如果更新成功
%>
<script>
alert('修改成功!');
window.location.href = "09managerSelf.jsp";
alert('修改成功!');//输出修改成功信息
window.location.href = "09managerSelf.jsp";//跳转到09managerSelf.jsp页面
</script>
<%
} else {
%>
<script>
alert('修改未成功!');
window.location.href = "09managerSelf.jsp";
alert('修改未成功!');//输出修改未成功信息
window.location.href = "09managerSelf.jsp";//跳转到09managerSelf.jsp页面
</script>
<%
}
} catch (Exception e) {
%>
<script>
alert('修改未成功!');
alert('修改未成功!');//捕获异常并输出修改未成功信息
window.location.href = "09managerSelf.jsp";
</script>
<%
@ -59,20 +59,20 @@
</script>
<%
}
}else if(email1!=null && email2!=null){
}else if(email1!=null && email2!=null){//如果email1和email2不为空
//out.println(psw1 + " " + psw2);
if (email1.equals(email2) && email1 != null && email2 != null && !email1.trim().equals("")
&& !email2.trim().equals("")) {
String sql = "update manager set EMAIL ='" + email1 + "' where ACCOUNT='" + id +"'";
&& !email2.trim().equals("")) {//如果email1等于email2且都不为空且不全是空格
String sql = "update manager set EMAIL ='" + email1 + "' where ACCOUNT='" + id +"'";//构建SQL更新语句
try {
int i = check.executeUpdate(sql);
if (i == 1) {
int i = check.executeUpdate(sql);//执行SQL更新语句
if (i == 1) {//如果更新成功
%>
<script>
alert('修改成功!');
alert('修改成功!');//输出修改成功信息
window.location.href = "09managerSelf.jsp";
</script>
@ -101,13 +101,13 @@
</script>
<%
}
}else if(name1!=null && name2!=null){
}else if(name1!=null && name2!=null){//如果name1和name2不为空
//out.println(psw1 + " " + psw2);
if (name1.equals(name2) && name1 != null && name2 != null && !name1.trim().equals("")
&& !name2.trim().equals("")) {
&& !name2.trim().equals("")) {//如果name1等于name2且都不为空且不全是空格
String sql = "update manager set NAME ='" + name1 + "' where ACCOUNT='" + id +"'";
try {
int i = check.executeUpdate(sql);

@ -1,39 +1,37 @@
package filter;
package filter; // 定义包名
import java.io.IOException;
import java.io.IOException; // 导入IOException类
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.Filter; // 导入Filter接口
import javax.servlet.FilterChain; // 导入FilterChain接口
import javax.servlet.FilterConfig; // 导入FilterConfig接口
import javax.servlet.ServletException; // 导入ServletException类
import javax.servlet.ServletRequest; // 导入ServletRequest接口
import javax.servlet.ServletResponse; // 导入ServletResponse接口
import javax.servlet.http.HttpServletRequest; // 导入HttpServletRequest类
import javax.servlet.http.HttpServletResponse; // 导入HttpServletResponse类
/**
*
* @author Mingyue
*
*/
import javax.servlet.*;
import java.io.IOException;
import javax.servlet.*; // 再次导入javax.servlet包可能是多余的
import java.io.IOException; // 再次导入IOException类可能是多余的
public class CharacterEncodingFilter implements Filter {
public void init(FilterConfig filterConfig) throws ServletException {
public class CharacterEncodingFilter implements Filter { // 定义一个实现Filter接口的类
public void init(FilterConfig filterConfig) throws ServletException { // 初始化方法接收FilterConfig对象
// 空实现,可以在这里进行一些初始化操作
}
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
servletRequest.setCharacterEncoding("UTF-8");
servletResponse.setCharacterEncoding("UTF-8");
filterChain.doFilter(servletRequest, servletResponse);
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { // 过滤方法,处理请求和响应
servletRequest.setCharacterEncoding("UTF-8"); // 设置请求的字符编码为UTF-8
servletResponse.setCharacterEncoding("UTF-8"); // 设置响应的字符编码为UTF-8
filterChain.doFilter(servletRequest, servletResponse); // 将请求和响应传递给下一个过滤器或目标资源
}
public void destroy() {
public void destroy() { // 销毁方法,在过滤器被销毁时调用
// 空实现,可以在这里进行一些清理操作
}
}

@ -17,22 +17,31 @@ import javax.servlet.http.HttpSession;
*/
public class ManagerFilter implements Filter {
// 当过滤器被销毁时调用此方法
public void destroy() {
}
// 执行过滤操作的方法
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
// 将请求对象转换为HttpServletRequest类型
HttpServletRequest req = (HttpServletRequest) request;
// 获取当前会话,如果不存在则创建一个新的会话
HttpSession session = req.getSession();
// 如果会话为空或会话中没有"manager"属性,则重定向到登录页面
if (session == null || session.getAttribute("manager") == null) {
// 将响应对象转换为HttpServletResponse类型
HttpServletResponse rep = (HttpServletResponse) response;
// 重定向到登录页面
rep.sendRedirect(req.getContextPath() + "/loginManager.html");
}
// 继续执行过滤链中的下一个过滤器或目标资源
chain.doFilter(request, response);
}
// 当过滤器被初始化时调用此方法
public void init(FilterConfig fConfig) throws ServletException {
}

@ -5,21 +5,21 @@ import java.text.SimpleDateFormat;
import java.util.Date;
public class CompareDate {
// 定义一个静态方法show接收两个字符串参数Str1和Str2返回两个日期之间的天数差
public static long show(String Str1, String Str2) {
long between = 0;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long between = 0; // 初始化between变量用于存储两个日期之间的毫秒数差
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 创建日期格式化对象,指定日期格式
try {
Date date1 = format.parse(Str1);
Date date2 = format.parse(Str2);
between = (date2.getTime() - date1.getTime());
System.out.println(date1);
System.out.println(date2);
Date date1 = format.parse(Str1); // 将字符串Str1解析为Date对象date1
Date date2 = format.parse(Str2); // 将字符串Str2解析为Date对象date2
between = (date2.getTime() - date1.getTime()); // 计算两个日期之间的毫秒数差
System.out.println(date1); // 打印第一个日期
System.out.println(date2); // 打印第二个日期
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
// 捕获并处理ParseException异常
e.printStackTrace(); // 打印异常堆栈信息
}
long days = between / (24 * 60 * 60 * 1000);
return days;
long days = between / (24 * 60 * 60 * 1000); // 将毫秒数差转换为天数
return days; // 返回两个日期之间的天数差
}
}

@ -1,52 +1,52 @@
package javabean;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat; // 导入SimpleDateFormat类用于格式化日期
import java.util.Calendar; // 导入Calendar类用于操作日期
import java.util.Date; // 导入Date类用于获取当前日期和时间
public class DateTime {
// 显示当前日期和时间,格式为"yyyy-MM-dd HH:mm:ss"
public static String show() {
SimpleDateFormat myFmt2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 等价于now.toLocaleString()
Date now = new Date();
return myFmt2.format(now);
SimpleDateFormat myFmt2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 创建日期格式化对象
Date now = new Date(); // 获取当前日期和时间
return myFmt2.format(now); // 返回格式化后的日期字符串
}
// 显示从当前日期开始n天后的日期和时间格式为"yyyy-MM-dd HH:mm:ss"
public static String show(int n) {
Date d = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String currdate = format.format(d);
Calendar ca = Calendar.getInstance();
ca.add(Calendar.DATE, n);// num为增加的天数可以改变的
d = ca.getTime();
String enddate = format.format(d);
return enddate;
Date d = new Date(); // 获取当前日期和时间
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 创建日期格式化对象
String currdate = format.format(d); // 格式化当前日期
Calendar ca = Calendar.getInstance(); // 获取日历实例
ca.add(Calendar.DATE, n); // 在当前日期基础上增加n天
d = ca.getTime(); // 获取增加天数后的日期
String enddate = format.format(d); // 格式化增加天数后的日期
return enddate; // 返回格式化后的日期字符串
}
// 只要年月日
// 显示从当前日期开始n天后的日期格式为"yyyy-MM-dd"
public static String showDate(int n) {
Date d = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String currdate = format.format(d);
Calendar ca = Calendar.getInstance();
ca.add(Calendar.DATE, n);// num为增加的天数可以改变的
d = ca.getTime();
String enddate = format.format(d);
return enddate;
Date d = new Date(); // 获取当前日期和时间
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); // 创建日期格式化对象
String currdate = format.format(d); // 格式化当前日期
Calendar ca = Calendar.getInstance(); // 获取日历实例
ca.add(Calendar.DATE, n); // 在当前日期基础上增加n天
d = ca.getTime(); // 获取增加天数后的日期
String enddate = format.format(d); // 格式化增加天数后的日期
return enddate; // 返回格式化后的日期字符串
}
// 只要月日
// 显示从当前日期开始n天后的月日格式为"MM-dd"
public static String showMD(int n) {
Date d = new Date();
SimpleDateFormat format = new SimpleDateFormat("MM-dd");
String currdate = format.format(d);
Calendar ca = Calendar.getInstance();
ca.add(Calendar.DATE, n);// num为增加的天数可以改变的
d = ca.getTime();
String enddate = format.format(d);
return enddate;
Date d = new Date(); // 获取当前日期和时间
SimpleDateFormat format = new SimpleDateFormat("MM-dd"); // 创建日期格式化对象
String currdate = format.format(d); // 格式化当前日期
Calendar ca = Calendar.getInstance(); // 获取日历实例
ca.add(Calendar.DATE, n); // 在当前日期基础上增加n天
d = ca.getTime(); // 获取增加天数后的日期
String enddate = format.format(d); // 格式化增加天数后的日期
return enddate; // 返回格式化后的日期字符串
}
}

@ -1,22 +1,23 @@
package javabean;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat; // 导入SimpleDateFormat类用于格式化日期
import java.util.Calendar; // 导入Calendar类用于操作日期
import java.util.Date; // 导入Date类用于获取当前日期和时间
public class EndTime {
// 定义一个静态方法show接收一个整数参数n表示增加的天数
public static String show(int n) {
Date d = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String currdate = format.format(d);
System.out.println("现在的日期是:" + currdate);
Date d = new Date(); // 获取当前日期和时间
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 创建日期格式化对象
String currdate = format.format(d); // 格式化当前日期
System.out.println("现在的日期是:" + currdate); // 打印当前日期
Calendar ca = Calendar.getInstance();
ca.add(Calendar.DATE, n);// num为增加的天数可以改变的
d = ca.getTime();
String enddate = format.format(d);
return enddate;
Calendar ca = Calendar.getInstance(); // 获取日历实例
ca.add(Calendar.DATE, n); // 在当前日期基础上增加n天
d = ca.getTime(); // 获取增加天数后的日期
String enddate = format.format(d); // 格式化增加天数后的日期
return enddate; // 返回格式化后的日期字符串
}
}

@ -6,27 +6,26 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class Manager {
@SuppressWarnings("null")
@SuppressWarnings("null") // 忽略空值警告
public String login(String user, String psw) throws ClassNotFoundException, SQLException {
// 检查用户名是否为空或仅包含空格
if (user == null || user.trim().equals("")) {
return "账号不能为空";
return "账号不能为空"; // 返回错误信息
} else if (psw == null || psw.trim().equals("")) {
return "密码不能为空";
return "密码不能为空"; // 返回错误信息
}
Connection connection = null;
PreparedStatement pstmt = null;
ResultSet resultSet = null;
String sql = "select * from manager where ACCOUNT=? and PASSWORD=?";
connection = Base.getConnection();
pstmt = (PreparedStatement) connection.prepareStatement(sql);
pstmt.setString(1, user);
pstmt.setString(2, psw);
resultSet = pstmt.executeQuery();
if (resultSet.next()) {
return "1";
Connection connection = null; // 数据库连接对象
PreparedStatement pstmt = null; // 预编译的SQL语句对象
ResultSet resultSet = null; // 结果集对象
String sql = "select * from manager where ACCOUNT=? and PASSWORD=?"; // SQL查询语句
connection = Base.getConnection(); // 获取数据库连接
pstmt = (PreparedStatement) connection.prepareStatement(sql); // 创建预编译的SQL语句对象
pstmt.setString(1, user); // 设置第一个参数(用户名)
pstmt.setString(2, psw); // 设置第二个参数(密码)
resultSet = pstmt.executeQuery(); // 执行查询并获取结果集
if (resultSet.next()) { // 如果结果集中有数据,表示登录成功
return "1"; // 返回成功标志
}
return "账号或密码错误";
return "账号或密码错误"; // 返回错误信息
}
}

@ -18,7 +18,7 @@ import net.sf.json.JSONObject;
/**
*
*
* @author Mingyue
*
*
*/
@WebServlet("/adminLogin")

@ -21,53 +21,53 @@ import net.sf.json.JSONObject;
/**
* Servlet implementation class Announcement
*/
@WebServlet("/manager/announcement")
@WebServlet("/manager/announcement") // 定义Servlet的URL映射路径
public class Announcement extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("application/json; charset=utf8");
resp.setContentType("application/json; charset=utf8"); // 设置响应内容类型和字符编码
// 准备数据
Connection connection = null;
PreparedStatement pstmt = null;
String sql = "";
ResultSet resultSet = null;
Connection connection = null; // 数据库连接对象
PreparedStatement pstmt = null; // SQL预编译语句对象
String sql = ""; // SQL查询语句字符串
ResultSet resultSet = null; // 结果集对象
// 返回数据
int code = 1;
String msg = "无数据";
JSONObject jsonObject = new JSONObject();
JSONArray jsonArray = new JSONArray();
int code = 1; // 状态码默认为1表示失败
String msg = "无数据"; // 消息提示,默认为"无数据"
JSONObject jsonObject = new JSONObject(); // JSON对象用于存储单条记录的数据
JSONArray jsonArray = new JSONArray(); // JSON数组用于存储所有记录的数据
try {
connection = (Connection) Base.getConnection();
sql = "select * from announcement";
pstmt = connection.prepareStatement(sql);
resultSet = pstmt.executeQuery();
while (resultSet.next()) {
jsonObject.put("id", resultSet.getString("id"));
jsonObject.put("title", resultSet.getString("title"));
jsonObject.put("detail", resultSet.getString("detail"));
jsonObject.put("publish_date", resultSet.getString("publish_date"));
connection = (Connection) Base.getConnection(); // 获取数据库连接
sql = "select * from announcement"; // 定义SQL查询语句
pstmt = connection.prepareStatement(sql); // 创建预编译语句对象
resultSet = pstmt.executeQuery(); // 执行查询并获取结果集
while (resultSet.next()) { // 遍历结果集
jsonObject.put("id", resultSet.getString("id")); // 将id字段添加到JSON对象中
jsonObject.put("title", resultSet.getString("title")); // 将title字段添加到JSON对象中
jsonObject.put("detail", resultSet.getString("detail")); // 将detail字段添加到JSON对象中
jsonObject.put("publish_date", resultSet.getString("publish_date")); // 将publish_date字段添加到JSON对象中
jsonArray.add(jsonObject);
jsonArray.add(jsonObject); // 将JSON对象添加到JSON数组中
}
if (!jsonArray.isEmpty()) {
code = 0;
msg = "查询成功";
if (!jsonArray.isEmpty()) { // 如果JSON数组不为空
code = 0; // 设置状态码为0表示成功
msg = "查询成功"; // 设置消息提示为"查询成功"
} else {
msg = "数据为空";
msg = "数据为空"; // 如果JSON数组为空设置消息提示为"数据为空"
}
} catch (ClassNotFoundException e) {
msg = "class找不到";
} catch (SQLException e) {
msg = "sql错误";
} catch (ClassNotFoundException e) { // 捕获类未找到异常
msg = "class找不到"; // 设置消息提示为"class找不到"
} catch (SQLException e) { // 捕获SQL异常
msg = "sql错误"; // 设置消息提示为"sql错误"
} finally {
try {
Base.closeResource(connection, pstmt, resultSet);
} catch (SQLException e) {
msg = "关闭失败";
Base.closeResource(connection, pstmt, resultSet); // 关闭数据库资源
} catch (SQLException e) { // 捕获关闭资源时的SQL异常
msg = "关闭失败"; // 设置消息提示为"关闭失败"
}
}
PrintWriter out = resp.getWriter();
out.print(Util.jsonResponse(code, msg, jsonArray.toString()));
PrintWriter out = resp.getWriter(); // 获取响应输出流
out.print(Util.jsonResponse(code, msg, jsonArray.toString())); // 输出JSON响应
}
}

@ -21,58 +21,58 @@ import net.sf.json.JSONObject;
/**
* Servlet implementation class AnnouncementAdd
*/
@WebServlet("/manager/announcementAdd")
@WebServlet("/manager/announcementAdd") // 定义Servlet的URL映射路径
public class AnnouncementAdd extends HttpServlet {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("application/json; charset=utf8");
resp.setContentType("application/json; charset=utf8"); // 设置响应内容类型和字符编码
// 接收参数
String id = req.getParameter("id");
String tit = req.getParameter("title");
String det = req.getParameter("detail");
DateTime date = new DateTime();
String time = date.show();
String id = req.getParameter("id"); // 获取请求中的id参数
String tit = req.getParameter("title"); // 获取请求中的title参数
String det = req.getParameter("detail"); // 获取请求中的detail参数
DateTime date = new DateTime(); // 创建DateTime对象用于获取当前时间
String time = date.show(); // 获取当前时间的字符串表示
// 准备参数
Connection connection = null;
PreparedStatement pstmt = null;
ResultSet resultSet = null;
int result = 0;
int count = 0;
Connection connection = null; // 数据库连接对象
PreparedStatement pstmt = null; // SQL预编译语句对象
ResultSet resultSet = null; // 结果集对象
int result = 0; // 执行更新操作的结果
int count = 0; // 记录影响的行数
// 返回参数
int code = 1;
String msg = "";
int code = 1; // 状态码默认为1表示失败
String msg = ""; // 消息提示
JSONArray jsonArray = new JSONArray();
JSONObject json = new JSONObject();
String sql = "insert into announcement(title, detail, publish_date) values(?,?,?)";
System.out.println(sql);
PrintWriter out = resp.getWriter();
JSONArray jsonArray = new JSONArray(); // JSON数组用于存储所有记录的数据
JSONObject json = new JSONObject(); // JSON对象用于存储单条记录的数据
String sql = "insert into announcement(title, detail, publish_date) values(?,?,?)"; // SQL插入语句
System.out.println(sql); // 打印SQL语句到控制台
PrintWriter out = resp.getWriter(); // 获取响应输出流
try {
connection = (Connection) Base.getConnection();
pstmt = connection.prepareStatement(sql);
pstmt.setString(1, tit);
pstmt.setString(2, det);
pstmt.setString(3, time);
connection = (Connection) Base.getConnection(); // 获取数据库连接
pstmt = connection.prepareStatement(sql); // 创建预编译语句对象
pstmt.setString(1, tit); // 设置第一个参数为公告标题
pstmt.setString(2, det); // 设置第二个参数为公告详情
pstmt.setString(3, time); // 设置第三个参数为公告发布时间
result = pstmt.executeUpdate();
} catch (SQLException e) {
result = pstmt.executeUpdate(); // 执行更新操作并获取影响的行数
} catch (SQLException e) { // 捕获SQL异常
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) { // 捕获类未找到异常
e.printStackTrace(); // 打印堆栈跟踪信息
} finally {
try {
Base.closeResource(connection, pstmt, null);
} catch (SQLException e) {
e.printStackTrace();
Base.closeResource(connection, pstmt, null); // 关闭数据库资源
} catch (SQLException e) { // 捕获关闭资源时的SQL异常
e.printStackTrace(); // 打印堆栈跟踪信息
}
}
if (result == 1) {
json.put("code", "0");
json.put("msg", "success");
} else {
json.put("code", "1");
json.put("msg", "error");
if (result == 1) { // 如果插入操作成功
json.put("code", "0"); // 设置状态码为0表示成功
json.put("msg", "success"); // 设置消息提示为"success"
} else { // 如果插入操作失败
json.put("code", "1"); // 设置状态码为1表示失败
json.put("msg", "error"); // 设置消息提示为"error"
}
out.write(json.toString());
out.write(json.toString()); // 输出JSON响应
}
}

@ -19,39 +19,39 @@ import javabean.Util;
/**
* Servlet implementation class AnnouncementDel
*/
@WebServlet("/manager/announcementDel")
@WebServlet("/manager/announcementDel") // 定义Servlet的URL映射路径
public class AnnouncementDel extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String id = req.getParameter("id");
String id = req.getParameter("id"); // 获取请求中的id参数
// 准备参数
String sql = "";
Connection connection = null;
PreparedStatement pstmt = null;
ResultSet resultSet = null;
int result = 0;
String sql = ""; // SQL语句字符串
Connection connection = null; // 数据库连接对象
PreparedStatement pstmt = null; // SQL预编译语句对象
ResultSet resultSet = null; // 结果集对象
int result = 0; // 执行更新操作的结果
// 返回参数
int code = 1;
String msg = "";
PrintWriter out = resp.getWriter();
int code = 1; // 状态码默认为1表示失败
String msg = ""; // 消息提示
PrintWriter out = resp.getWriter(); // 获取响应输出流
try {
connection = (Connection) Base.getConnection();
sql = "delete from announcement where id=?";
pstmt = connection.prepareStatement(sql);
pstmt.setString(1, id);
result = pstmt.executeUpdate();
if (result == 1) {
code = 0;
msg = "删除成功";
} else {
msg = "删除失败";
connection = (Connection) Base.getConnection(); // 获取数据库连接
sql = "delete from announcement where id=?"; // 设置SQL删除语句
pstmt = connection.prepareStatement(sql); // 创建预编译语句对象
pstmt.setString(1, id); // 设置第一个参数为公告ID
result = pstmt.executeUpdate(); // 执行更新操作并获取影响的行数
if (result == 1) { // 如果删除操作成功
code = 0; // 设置状态码为0表示成功
msg = "删除成功"; // 设置消息提示为"删除成功"
} else { // 如果删除操作失败
msg = "删除失败"; // 设置消息提示为"删除失败"
}
} catch (ClassNotFoundException e) {
msg = "class not found";
} catch (SQLException e) {
msg = "sql错误";
} catch (ClassNotFoundException e) { // 捕获类未找到异常
msg = "class not found"; // 设置消息提示为"class not found"
} catch (SQLException e) { // 捕获SQL异常
msg = "sql错误"; // 设置消息提示为"sql错误"
}
out.print(Util.jsonResponse(code, msg, null));
out.print(Util.jsonResponse(code, msg, null)); // 输出JSON响应
}

@ -21,61 +21,61 @@ import net.sf.json.JSONObject;
/**
* Servlet implementation class AnnouncementEdit
*/
@WebServlet("/manager/announcementEdit")
@WebServlet("/manager/announcementEdit") // 定义Servlet的URL映射路径
public class AnnouncementEdit extends HttpServlet {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("application/json; charset=utf8");
resp.setContentType("application/json; charset=utf8"); // 设置响应内容类型和字符编码
// 接收参数
String id = req.getParameter("id");
String tit = req.getParameter("title");
String det = req.getParameter("detail");
String id = req.getParameter("id"); // 获取请求中的公告ID参数
String tit = req.getParameter("title"); // 获取请求中的公告标题参数
String det = req.getParameter("detail"); // 获取请求中的公告详情参数
// 准备参数
String sql = "";
Connection connection = null;
PreparedStatement pstmt = null;
ResultSet resultSet = null;
int result = 0;
String sql = ""; // SQL语句字符串
Connection connection = null; // 数据库连接对象
PreparedStatement pstmt = null; // SQL预编译语句对象
ResultSet resultSet = null; // 结果集对象
int result = 0; // 执行更新操作的结果
// 返回参数
int code = 1;
String msg = "";
PrintWriter out = resp.getWriter();
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
int code = 1; // 状态码默认为1表示失败
String msg = ""; // 消息提示
PrintWriter out = resp.getWriter(); // 获取响应输出流
JSONArray jsonArray = new JSONArray(); // JSON数组对象
JSONObject jsonObject = new JSONObject(); // JSON对象
// 进行查询
if (tit == null || tit.equals("") || det == null || det.equals("")) {
msg = "参数不能为空";
out.print(Util.jsonResponse(code, msg, null));
if (tit == null || tit.equals("") || det == null || det.equals("")) { // 检查参数是否为空
msg = "参数不能为空"; // 设置消息提示为"参数不能为空"
out.print(Util.jsonResponse(code, msg, null)); // 输出JSON响应
} else {
try {
connection = (Connection) Base.getConnection();
connection = (Connection) Base.getConnection(); // 获取数据库连接
// 更新公告
sql = "update announcement set title=?, detail=? where id=?";
pstmt = connection.prepareStatement(sql);
pstmt.setString(1, tit);
pstmt.setString(2, det);
pstmt.setString(3, id);
result = pstmt.executeUpdate();
sql = "update announcement set title=?, detail=? where id=?"; // 设置SQL更新语句
pstmt = connection.prepareStatement(sql); // 创建预编译语句对象
pstmt.setString(1, tit); // 设置第一个参数为公告标题
pstmt.setString(2, det); // 设置第二个参数为公告详情
pstmt.setString(3, id); // 设置第三个参数为公告ID
result = pstmt.executeUpdate(); // 执行更新操作并获取影响的行数
// 返回数据
if (result == 1) {
code = 0;
msg = "修改成功";
} else {
msg = "修改失败";
if (result == 1) { // 如果更新操作成功
code = 0; // 设置状态码为0表示成功
msg = "修改成功"; // 设置消息提示为"修改成功"
} else { // 如果更新操作失败
msg = "修改失败"; // 设置消息提示为"修改失败"
}
} catch (ClassNotFoundException e) {
msg = "class not found";
} catch (SQLException e) {
msg = "sql错误";
} catch (ClassNotFoundException e) { // 捕获类未找到异常
msg = "class not found"; // 设置消息提示为"class not found"
} catch (SQLException e) { // 捕获SQL异常
msg = "sql错误"; // 设置消息提示为"sql错误"
} finally {
try {
Base.closeResource(connection, pstmt, resultSet);
} catch (SQLException e) {
e.printStackTrace();
Base.closeResource(connection, pstmt, resultSet); // 关闭数据库资源
} catch (SQLException e) { // 捕获关闭资源时的SQL异常
e.printStackTrace(); // 打印堆栈跟踪信息
}
}
out.print(Util.jsonResponse(code, msg, null));
out.print(Util.jsonResponse(code, msg, null)); // 输出JSON响应
}
}

@ -21,19 +21,22 @@ import net.sf.json.JSONObject;
public class BorrowTable extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// 设置响应内容类型和字符编码
resp.setContentType("application/json; charset=utf8");
// 接收参数
String limit = req.getParameter("limit");
String page = req.getParameter("page");
String condition = (String) req.getParameter("condition");
String conditionValue = (String) req.getParameter("conditionValue");
String limit = req.getParameter("limit"); // 每页显示的记录数
String page = req.getParameter("page"); // 当前页码
String condition = (String) req.getParameter("condition"); // 查询条件字段
String conditionValue = (String) req.getParameter("conditionValue"); // 查询条件值
String where = ""; // 无限制条件
if (page == null) {
page = "1";
page = "1"; // 默认第一页
}
if (limit == null) {
limit = "10";
limit = "10"; // 默认每页10条记录
}
// 准备查询
Connection connection = null;
PreparedStatement pstmt = null;
@ -42,30 +45,32 @@ public class BorrowTable extends HttpServlet {
ResultSet countSet = null;
String sql = "";
String countSql = "";
// 准备返回参数
int code = 1;
String msg = "无数据";
int count = 0;
int code = 1; // 状态码1表示失败0表示成功
String msg = "无数据"; // 提示信息
int count = 0; // 总记录数
JSONObject jsonData = new JSONObject(); // 单条记录的JSON对象
JSONArray jsonArray = new JSONArray(); // 所有记录的JSON数组
JSONObject jsonResult = new JSONObject(); // 最终返回的JSON对象
JSONObject jsonData = new JSONObject();
JSONArray jsonArray = new JSONArray();
JSONObject jsonResult = new JSONObject();
// 进行查询
try {
connection = (Connection) Base.getConnection();
sql = "select * from borrow_books where manager_id is not null";
connection = (Connection) Base.getConnection(); // 获取数据库连接
sql = "select * from borrow_books where manager_id is not null"; // SQL查询语句
if (condition != null && conditionValue != null && !condition.equals("") && !conditionValue.equals("")) {
where = " and " + condition + " like '%" + conditionValue + "%' ";
sql += where;
where = " and " + condition + " like '%" + conditionValue + "%' "; // 添加查询条件
sql += where; // 拼接查询条件到SQL语句中
}
sql += " limit ?,?";// 1 10 (1-1)*10
System.out.println("???" + sql);
pstmt = connection.prepareStatement(sql);
pstmt.setInt(1, (Integer.parseInt(page) - 1) * Integer.parseInt(limit));
pstmt.setInt(2, Integer.parseInt(limit));
resultSet = pstmt.executeQuery();
while (resultSet.next()) {
jsonData.put("id", resultSet.getString("id"));
sql += " limit ?,?"; // 分页查询占位符用于防止SQL注入
System.out.println("???" + sql); // 打印调试信息
pstmt = connection.prepareStatement(sql); // 预编译SQL语句
pstmt.setInt(1, (Integer.parseInt(page) - 1) * Integer.parseInt(limit)); // 设置第一个占位符的值(起始记录)
pstmt.setInt(2, Integer.parseInt(limit)); // 设置第二个占位符的值(每页记录数)
resultSet = pstmt.executeQuery(); // 执行查询并获取结果集
while (resultSet.next()) { // 遍历结果集
jsonData.put("id", resultSet.getString("id")); // 将每条记录的各个字段添加到JSON对象中
jsonData.put("card_id", resultSet.getString("card_id"));
jsonData.put("book_id", resultSet.getString("book_id"));
jsonData.put("borrow_date", resultSet.getString("borrow_date"));
@ -73,40 +78,38 @@ public class BorrowTable extends HttpServlet {
jsonData.put("return_date", resultSet.getString("return_date"));
jsonData.put("illegal", resultSet.getString("illegal"));
jsonData.put("manager_id", resultSet.getString("manager_id"));
jsonArray.add(jsonData);
jsonArray.add(jsonData); // 将JSON对象添加到JSON数组中
}
countSql = "select count(*) as count from borrow_books where manager_id is not null";
countSql += where;
countPstmt = connection.prepareStatement(countSql);
countSet = countPstmt.executeQuery();
if (countSet.next()) {
count = countSet.getInt("count");
countSql = "select count(*) as count from borrow_books where manager_id is not null"; // 统计总记录数的SQL语句
countSql += where; // 添加查询条件到统计SQL语句中
countPstmt = connection.prepareStatement(countSql); // 预编译统计SQL语句
countSet = countPstmt.executeQuery(); // 执行统计查询并获取结果集
if (countSet.next()) { // 如果结果集中有数据
count = countSet.getInt("count"); // 获取总记录数
}
if (!jsonArray.isEmpty()) {
code = 0;
msg = "查询成功";
if (!jsonArray.isEmpty()) { // 如果查询结果不为空
code = 0; // 设置状态码为0表示成功
msg = "查询成功"; // 设置提示信息为查询成功
}
} catch (ClassNotFoundException e) {
msg = "class没找到";
} catch (SQLException e) {
msg = "sql错误";
} finally {
} catch (ClassNotFoundException e) { // 捕获类未找到异常
msg = "class没找到"; // 设置提示信息为类未找到
} catch (SQLException e) { // 捕获SQL异常
msg = "sql错误"; // 设置提示信息为SQL错误
} finally { // 关闭资源
try {
Base.closeResource(null, pstmt, resultSet);
Base.closeResource(connection, countPstmt, countSet);
} catch (SQLException e) {
msg = "关闭资源失败";
Base.closeResource(null, pstmt, resultSet); // 关闭PreparedStatement和ResultSet资源
Base.closeResource(connection, countPstmt, countSet); // 关闭Connection、PreparedStatement和ResultSet资源
} catch (SQLException e) { // 捕获SQL异常
msg = "关闭资源失败"; // 设置提示信息为关闭资源失败
}
}
// 返回数据
jsonResult.put("code", code);
jsonResult.put("count", count);
jsonResult.put("msg", msg);
jsonResult.put("data", jsonArray.toArray());
PrintWriter out = resp.getWriter();
out.print(jsonResult.toString());
jsonResult.put("code", code); // 将状态码添加到返回的JSON对象中
jsonResult.put("count", count); // 将总记录数添加到返回的JSON对象中
jsonResult.put("msg", msg); // 将提示信息添加到返回的JSON对象中
jsonResult.put("data", jsonArray.toArray()); // 将查询结果添加到返回的JSON对象中
PrintWriter out = resp.getWriter(); // 获取输出流
out.print(jsonResult.toString()); // 输出JSON字符串
}
}

@ -15,44 +15,44 @@ import javax.servlet.http.HttpSession;
import javabean.Manager;
import net.sf.json.JSONObject;
@WebServlet("/managerLogin")
@WebServlet("/managerLogin") // 定义Servlet的URL映射
public class ManagerLogin extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.getWriter().append("Served at: ").append(request.getContextPath());
response.getWriter().append("Served at: ").append(request.getContextPath()); // 处理GET请求返回简单的响应
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// 设置头文件
// 设置响应内容类型和字符编码
response.setContentType("application/json; charset=utf8");
PrintWriter out = response.getWriter();
// 获取账号密码
PrintWriter out = response.getWriter(); // 获取输出流
// 从请求中获取用户名和密码参数
String user = request.getParameter("user");
String psw = request.getParameter("psw");
// 设置响应map
// 创建一个HashMap来存储响应数据
HashMap<String, Object> hashMap = new HashMap<String, Object>();
Manager manager = new Manager();
String result = null;
Manager manager = new Manager(); // 创建Manager对象
String result = null; // 用于存储登录结果
try {
result = manager.login(user, psw);
result = manager.login(user, psw); // 调用Manager对象的login方法进行登录验证
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
e.printStackTrace(); // 捕获并打印异常信息
}
if (result.equals("1")) {
HttpSession session = request.getSession();
session.setAttribute("manager", user);
session.setAttribute("manager_first", "1"); // 登录
hashMap.put("code", 0);
hashMap.put("msg", "登录成功");
hashMap.put("url", request.getContextPath() + "/manager/01nav.jsp");
} else {
hashMap.put("code", 1);
hashMap.put("msg", result);
if (result.equals("1")) { // 如果登录成功
HttpSession session = request.getSession(); // 获取当前会话
session.setAttribute("manager", user); // 在会话中存储用户名
session.setAttribute("manager_first", "1"); // 标记为首次登录
hashMap.put("code", 0); // 设置响应码为0表示成功
hashMap.put("msg", "登录成功"); // 设置响应消息为登录成功
hashMap.put("url", request.getContextPath() + "/manager/01nav.jsp"); // 设置跳转URL
} else { // 如果登录失败
hashMap.put("code", 1); // 设置响应码为1表示失败
hashMap.put("msg", result); // 设置响应消息为错误信息
}
// response.sendRedirect(request.getContextPath() +"/test.jsp");
// 将HashMap转换为JSON对象并写入响应
JSONObject json = JSONObject.fromObject(hashMap);
out.write(json.toString());

@ -1,29 +1,29 @@
package servlet.manager;
package servlet.manager; // 定义包名
import java.io.IOException;
import java.io.IOException; // 导入IOException类
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletException; // 导入ServletException类
import javax.servlet.annotation.WebServlet; // 导入WebServlet注解
import javax.servlet.http.HttpServlet; // 导入HttpServlet类
import javax.servlet.http.HttpServletRequest; // 导入HttpServletRequest类
import javax.servlet.http.HttpServletResponse; // 导入HttpServletResponse类
import javax.servlet.http.HttpSession; // 导入HttpSession类
/**
* Servlet implementation class Quit
*/
@WebServlet("/manager/quit")
public class Quit extends HttpServlet {
private static final long serialVersionUID = 1L;
@WebServlet("/manager/quit") // 定义Servlet的URL映射
public class Quit extends HttpServlet { // 继承HttpServlet类
private static final long serialVersionUID = 1L; // 序列化版本号
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // 重写doGet方法
// TODO Auto-generated method stub
HttpSession session = req.getSession();
if (session.getAttribute("manager") != null) {
session.removeAttribute("manager");
HttpSession session = req.getSession(); // 获取当前会话
if (session.getAttribute("manager") != null) { // 如果会话中存在"manager"属性
session.removeAttribute("manager"); // 移除"manager"属性
}
resp.sendRedirect(req.getContextPath() + "/loginManager.html");
resp.sendRedirect(req.getContextPath() + "/loginManager.html"); // 重定向到登录页面
}
}

@ -20,94 +20,94 @@ import net.sf.json.JSONObject;
/**
* Servlet implementation class ReturnTable
*/
@WebServlet("/manager/returnTable")
public class ReturnTable extends HttpServlet {
@WebServlet("/manager/returnTable") // 定义Servlet的URL映射
public class ReturnTable extends HttpServlet { // 继承HttpServlet类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("application/json; charset=utf8");
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // 重写doGet方法
resp.setContentType("application/json; charset=utf8"); // 设置响应内容类型为JSON编码为UTF-8
// 接收参数
String limit = req.getParameter("limit");
String page = req.getParameter("page");
String condition = (String) req.getParameter("condition");
String conditionValue = (String) req.getParameter("conditionValue");
String where = ""; // 无限制条件
if (page == null) {
page = "1";
String limit = req.getParameter("limit"); // 获取请求中的limit参数
String page = req.getParameter("page"); // 获取请求中的page参数
String condition = (String) req.getParameter("condition"); // 获取请求中的condition参数
String conditionValue = (String) req.getParameter("conditionValue"); // 获取请求中的conditionValue参数
String where = ""; // 初始化where子句为空字符串
if (page == null) { // 如果page参数为空
page = "1"; // 默认设置为1
}
if (limit == null) {
limit = "10";
if (limit == null) { // 如果limit参数为空
limit = "10"; // 默认设置为10
}
// 准备查询
Connection connection = null;
PreparedStatement pstmt = null;
PreparedStatement countPstmt = null;
ResultSet resultSet = null;
ResultSet countSet = null;
String sql = "";
String countSql = "";
Connection connection = null; // 数据库连接对象
PreparedStatement pstmt = null; // 预编译SQL语句对象
PreparedStatement countPstmt = null; // 用于计数的预编译SQL语句对象
ResultSet resultSet = null; // 结果集对象
ResultSet countSet = null; // 计数结果集对象
String sql = ""; // SQL查询语句
String countSql = ""; // 计数SQL查询语句
// 准备返回参数
int code = 1;
String msg = "无数据";
int count = 0;
int code = 1; // 返回代码默认为1表示失败
String msg = "无数据"; // 返回消息,默认为"无数据"
int count = 0; // 总记录数
JSONObject jsonData = new JSONObject();
JSONArray jsonArray = new JSONArray();
JSONObject jsonResult = new JSONObject();
JSONObject jsonData = new JSONObject(); // JSON对象用于存储单条记录的数据
JSONArray jsonArray = new JSONArray(); // JSON数组用于存储所有记录的数据
JSONObject jsonResult = new JSONObject(); // JSON对象用于返回最终结果
// 进行查询
try {
connection = (Connection) Base.getConnection();
sql = "select * from borrow_books where manager_id is null";
if (condition != null && conditionValue != null && !condition.equals("") && !conditionValue.equals("")) {
where = " and " + condition + " like '%" + conditionValue + "%' ";
sql += where;
connection = (Connection) Base.getConnection(); // 获取数据库连接
sql = "select * from borrow_books where manager_id is null"; // 基础查询语句
if (condition != null && conditionValue != null && !condition.equals("") && !conditionValue.equals("")) { // 如果存在条件
where = " and " + condition + " like '%" + conditionValue + "%' "; // 拼接where子句
sql += where; // 将where子句添加到查询语句中
}
sql += " limit ?,?";// 1 10 (1-1)*10
System.out.println("???" + sql);
pstmt = connection.prepareStatement(sql);
pstmt.setInt(1, (Integer.parseInt(page) - 1) * Integer.parseInt(limit));
pstmt.setInt(2, Integer.parseInt(limit));
resultSet = pstmt.executeQuery();
while (resultSet.next()) {
jsonData.put("id", resultSet.getString("id"));
jsonData.put("card_id", resultSet.getString("card_id"));
jsonData.put("book_id", resultSet.getString("book_id"));
jsonData.put("borrow_date", resultSet.getString("borrow_date"));
jsonData.put("end_date", resultSet.getString("end_date"));
sql += " limit ?,?"; // 添加分页限制
System.out.println("???" + sql); // 打印调试信息
pstmt = connection.prepareStatement(sql); // 预编译SQL语句
pstmt.setInt(1, (Integer.parseInt(page) - 1) * Integer.parseInt(limit)); // 设置第一个参数(偏移量)
pstmt.setInt(2, Integer.parseInt(limit)); // 设置第二个参数(每页记录数)
resultSet = pstmt.executeQuery(); // 执行查询
while (resultSet.next()) { // 遍历结果集
jsonData.put("id", resultSet.getString("id")); // 获取并存储id字段
jsonData.put("card_id", resultSet.getString("card_id")); // 获取并存储card_id字段
jsonData.put("book_id", resultSet.getString("book_id")); // 获取并存储book_id字段
jsonData.put("borrow_date", resultSet.getString("borrow_date")); // 获取并存储borrow_date字段
jsonData.put("end_date", resultSet.getString("end_date")); // 获取并存储end_date字段
jsonArray.add(jsonData);
jsonArray.add(jsonData); // 将当前记录添加到JSON数组中
}
countSql = "select count(*) as count from borrow_books where manager_id is null";
countSql += where;
countPstmt = connection.prepareStatement(countSql);
countSet = countPstmt.executeQuery();
if (countSet.next()) {
count = countSet.getInt("count");
countSql = "select count(*) as count from borrow_books where manager_id is null"; // 基础计数查询语句
countSql += where; // 添加where子句到计数查询语句中
countPstmt = connection.prepareStatement(countSql); // 预编译计数SQL语句
countSet = countPstmt.executeQuery(); // 执行计数查询
if (countSet.next()) { // 如果计数结果集有数据
count = countSet.getInt("count"); // 获取总记录数
}
if (!jsonArray.isEmpty()) {
code = 0;
msg = "查询成功";
if (!jsonArray.isEmpty()) { // 如果JSON数组不为空
code = 0; // 设置返回代码为0表示成功
msg = "查询成功"; // 设置返回消息为"查询成功"
}
} catch (ClassNotFoundException e) {
msg = "class没找到";
} catch (SQLException e) {
msg = "sql错误";
} catch (ClassNotFoundException e) { // 捕获类未找到异常
msg = "class没找到"; // 设置错误消息
} catch (SQLException e) { // 捕获SQL异常
msg = "sql错误"; // 设置错误消息
} finally {
try {
Base.closeResource(null, pstmt, resultSet);
Base.closeResource(connection, countPstmt, countSet);
} catch (SQLException e) {
msg = "关闭资源失败";
Base.closeResource(null, pstmt, resultSet); // 关闭资源
Base.closeResource(connection, countPstmt, countSet); // 关闭资源
} catch (SQLException e) { // 捕获SQL异常
msg = "关闭资源失败"; // 设置错误消息
}
}
// 返回数据
jsonResult.put("code", code);
jsonResult.put("count", count);
jsonResult.put("msg", msg);
jsonResult.put("data", jsonArray.toArray());
PrintWriter out = resp.getWriter();
out.print(jsonResult.toString());
jsonResult.put("code", code); // 将返回代码添加到JSON结果中
jsonResult.put("count", count); // 将总记录数添加到JSON结果中
jsonResult.put("msg", msg); // 将返回消息添加到JSON结果中
jsonResult.put("data", jsonArray.toArray()); // 将数据添加到JSON结果中
PrintWriter out = resp.getWriter(); // 获取输出流
out.print(jsonResult.toString()); // 输出JSON结果
}
/**

Loading…
Cancel
Save