From 11f9269b771741fddbad4745d96a5986af401f62 Mon Sep 17 00:00:00 2001 From: heyou <3616724175@qq.com> Date: Mon, 16 Dec 2024 10:18:09 +0800 Subject: [PATCH] hy2 --- sql/bookstore.sql | 127 ++-- web/pages/client/index.jsp | 47 +- web/pages/client/top.jsp | 15 +- web/pages/error/error404.jsp | 14 +- web/pages/error/error500.jsp | 17 +- web/pages/error/errorManager.jsp | 18 +- web/static/script/jquery-1.7.2.js | 960 +++++++++++++++++------------- 7 files changed, 679 insertions(+), 519 deletions(-) diff --git a/sql/bookstore.sql b/sql/bookstore.sql index 4baa7bf..62c6171 100644 --- a/sql/bookstore.sql +++ b/sql/bookstore.sql @@ -20,62 +20,87 @@ INSERT INTO t_user(username,`password`,email,address) VALUES('admin','admin','ad ## 查询表 SELECT * FROM t_user; +-- 创建名为t_book的表 CREATE TABLE t_book( - `id` INT PRIMARY KEY AUTO_INCREMENT, - `name` VARCHAR(100), - `price` DECIMAL(11,2), - `author` VARCHAR(100), - `classification` VARCHAR(20), - `sales` INT, - `stock` INT, - `imgpath` VARCHAR(200) + -- 定义名为id的字段,数据类型为INT(整数类型),将其设置为主键,并且设置为自增(AUTO_INCREMENT),这样每插入一条新记录时,该字段的值会自动按顺序递增,用于为每本图书生成唯一的标识符 + `id` INT PRIMARY KEY AUTO_INCREMENT, + -- 定义名为name的字段,数据类型为VARCHAR(可变长度字符串),长度为100,用于存储图书的书名信息 + `name` VARCHAR(100), + -- 定义名为price的字段,数据类型为DECIMAL(精确数值类型),总长度为11位,其中小数部分占2位,用于存储图书的价格信息 + `price` DECIMAL(11,2), + -- 定义名为author的字段,数据类型为VARCHAR,长度为100,用来记录图书的作者姓名 + `author` VARCHAR(100), + -- 定义名为classification的字段,数据类型为VARCHAR,长度为20,可用于存储图书的分类信息,例如文学、科技等类别 + `classification` VARCHAR(20), + -- 定义名为sales的字段,数据类型为INT,用于记录图书的销量情况 + `sales` INT, + -- 定义名为stock的字段,数据类型为INT,用于表示图书的库存数量 + `stock` INT, + -- 定义名为imgpath的字段,数据类型为VARCHAR,长度为200,可用于存储图书封面图片的路径信息,方便在应用中展示图书封面图片 + `imgpath` VARCHAR(200) ); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('解忧杂货店','东野圭吾','文学',27.20,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('边城','沈从文','文学',23.00,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('中国哲学史','冯友兰','文学',44.5,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('苏东坡传','林语堂','文学',19.30,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('百年孤独','马尔克斯','文学',29.50,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('扶桑','严歌苓','文学',19.8,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('给孩子的诗','北岛','文学',22.20,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('为奴十二年','所罗门','文学',16.5,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('平凡的世界','路遥','文学',55.00,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('悟空传','今何在','文学',14.00,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('硬派健身','斌卡','文学',31.20,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('从晚清到民国','唐德刚','文学',39.90,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('三体','刘慈欣','文学',56.5,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('看见','柴静','文学',19.50,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('活着','余华','文学',11.00,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('小王子','安托万','文学',19.20,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('我们仨','杨绛','文学',11.30,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification,price, sales , stock , imgpath) VALUES('生命不息,折腾不止','罗永浩','文学',25.20,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification,price, sales , stock , imgpath) VALUES('皮囊','蔡崇达','文学',23.90,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('恰到好处的幸福','毕淑敏','文学',16.40,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('大数据预测','埃里克','文学',37.20,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('人月神话','布鲁克斯','文学',55.90,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('C语言入门经典','霍尔顿','文学',45.00,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('数学之美','吴军','文学',29.90,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('Java编程思想','埃史尔','文学',70.50,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('设计模式之禅','秦小波','文学',20.20,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('图解机器学习','杉山将','文学',33.80,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('艾伦图灵传','安德鲁','文学',47.20,100,100,'static/img/default.jpg'); -INSERT INTO t_book (name, author, classification, price, sales , stock , imgpath) VALUES('教父','马里奥普佐','文学',29.00,100,100,'static/img/default.jpg'); - +-- 向t_book表中插入一条图书数据记录,指定要插入值的字段为(name, author, classification, price, sales, stock, imgpath),并对应给出具体的值,分别为图书的书名、作者、分类、价格、销量、库存以及封面图片路径 +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('解忧杂货店','东野圭吾','文学',27.20,100,100,'static/img/default.jpg'); +-- 同样是向t_book表中插入图书数据记录,以下每条INSERT语句的结构和作用与上面类似,只是对应不同的图书信息 +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('边城','沈从文','文学',23.00,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('中国哲学史','冯友兰','文学',44.5,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('苏东坡传','林语堂','文学',19.30,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('百年孤独','马尔克斯','文学',29.50,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('扶桑','严歌苓','文学',19.8,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('给孩子的诗','北岛','文学',22.20,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('为奴十二年','所罗门','文学',16.5,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('平凡的世界','路遥','文学',55.00,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('悟空传','今何在','文学',14.00,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('硬派健身','斌卡','文学',31.20,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('从晚清到民国','唐德刚','文学',39.90,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('三体','刘慈欣','文学',56.5,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('看见','柴静','文学',19.50,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('活着','余华','文学',11.00,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('小王子','安托万','文学',19.20,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('我们仨','杨绛','文学',11.30,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification,price, sales, stock, imgpath) VALUES('生命不息,折腾不止','罗永浩','文学',25.20,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification,price, sales, stock, imgpath) VALUES('皮囊','蔡崇达','文学',23.90,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('恰到好处的幸福','毕淑敏','文学',16.40,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('大数据预测','埃里克','文学',37.20,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('人月神话','布鲁克斯','文学',55.90,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('C语言入门经典','霍尔顿','文学',45.00,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('数学之美','吴军','文学',29.90,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('Java编程思想','埃史尔','文学',70.50,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('设计模式之禅','秦小波','文学',20.20,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('图解机器学习','杉山将','文学',33.80,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('艾伦图灵传','安德鲁','文学',47.20,100,100,'static/img/default.jpg'); +INSERT INTO t_book (name, author, classification, price, sales, stock, imgpath) VALUES('教父','马里奥普佐','文学',29.00,100,100,'static/img/default.jpg'); +-- 创建名为t_order的表 CREATE TABLE t_order( - `order_id` VARCHAR(50) PRIMARY KEY, - `create_time` DATETIME, - `price` DECIMAL(11,2), - `status` INT, - `user_id` INT, - FOREIGN KEY(`user_id`) REFERENCES t_user(`id`) + -- 定义名为order_id的字段,数据类型为VARCHAR(可变长度字符串),长度为50,并且将该字段设置为主键,用于唯一标识每条订单记录 + `order_id` VARCHAR(50) PRIMARY KEY, + -- 定义名为create_time的字段,数据类型为DATETIME(用于存储日期和时间信息),用来记录订单创建的时间 + `create_time` DATETIME, + -- 定义名为price的字段,数据类型为DECIMAL(精确数值类型),总长度为11位,其中小数部分占2位,用于存储订单的价格信息 + `price` DECIMAL(11,2), + -- 定义名为status的字段,数据类型为INT(整数类型),可能用于表示订单的状态,比如不同的数值对应不同的订单处理阶段等情况 + `status` INT, + -- 定义名为user_id的字段,数据类型为INT,该字段将作为外键,与另一个表(t_user)中的id字段建立关联关系 + `user_id` INT, + -- 使用FOREIGN KEY关键字为user_id字段添加外键约束,指定它参照t_user表中的id字段,意味着t_order表中的user_id值必须在t_user表的id字段值中存在,以此建立起两张表之间的关联,通常表示订单所属的用户 + FOREIGN KEY(`user_id`) REFERENCES t_user(`id`) ); +-- 创建名为t_order_item的表 CREATE TABLE t_order_item( - `id` INT PRIMARY KEY AUTO_INCREMENT, - `name` VARCHAR(100), - `count` INT, - `price` DECIMAL(11,2), - `total_price` DECIMAL(11,2), - `order_id` VARCHAR(50), - FOREIGN KEY(`order_id`) REFERENCES t_order(`order_id`) + -- 定义名为id的字段,数据类型为INT(整数类型),并将该字段设置为主键,同时设置为自增(AUTO_INCREMENT),这样每当插入一条新记录时,该字段的值会自动按顺序递增,常用于为每条记录生成唯一的标识符 + `id` INT PRIMARY KEY AUTO_INCREMENT, + -- 定义名为name的字段,数据类型为VARCHAR,长度为100,可用于存储商品名称等相关信息,比如订单中具体商品的名字 + `name` VARCHAR(100), + -- 定义名为count的字段,数据类型为INT,用于记录商品的数量,比如某个商品在该订单中的购买数量 + `count` INT, + -- 定义名为price的字段,数据类型为DECIMAL,总长度11位,小数部分占2位,可能用于存储单个商品的价格信息 + `price` DECIMAL(11,2), + -- 定义名为total_price的字段,数据类型为DECIMAL,总长度11位,小数部分占2位,用于存储该商品的总价(可能是通过商品单价乘以数量计算得出) + `total_price` DECIMAL(11,2), + -- 定义名为order_id的字段,数据类型为VARCHAR,长度为50,该字段将作为外键,与t_order表中的order_id字段建立关联关系 + `order_id` VARCHAR(50), + -- 使用FOREIGN KEY关键字为order_id字段添加外键约束,指定它参照t_order表中的order_id字段,意味着t_order_item表中的order_id值必须在t_order表的order_id字段值中存在,以此建立起两张表之间的关联,表明该订单项所属的订单 + FOREIGN KEY(`order_id`) REFERENCES t_order(`order_id`) ); diff --git a/web/pages/client/index.jsp b/web/pages/client/index.jsp index 79b2494..077ce4e 100644 --- a/web/pages/client/index.jsp +++ b/web/pages/client/index.jsp @@ -1,11 +1,6 @@ <%-- - Created by IntelliJ IDEA. - User: jhu - Date: 2020/10/5 - Time: 15:44 - To change this template use File | Settings | File Templates. + 此文件的创建信息注释,表明是由 IntelliJ IDEA 创建,作者是 jhu,创建日期是 2020 年 10 月 5 日,时间是 15 时 44 分,并且提示修改此模板的相关设置路径。 --%> - <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> @@ -13,17 +8,21 @@ 书城首页 + <%-- 包含公共的头部页面(header.jsp),可能包含一些通用的样式、脚本或者页面头部结构相关的内容,方便复用。 --%> <%@include file="/pages/common/header.jsp"%>