书城项目全部代码4

简介: 书城项目全部代码4

orderDetail 代码

orderDetail.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2021/9/23
  Time: 17:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>订单详情</title>
    <%--静态包含 base标签,css样式,jquery文件 --%>
    <%@ include file="/pages/common/head.jsp"%>
</head>
<body>
<%@ include file="/pages/common/login_sucess_menu.jsp"%>
<div id="main">
        <table>
            <tr>
                <td>商品名称</td>
                <td>数量</td>
                <td>单价</td>
                <td>总价</td>
                <td>订单号</td>
            </tr>
<%--            ${sessionScope.orderItems}--%>
            <c:if test="${not empty sessionScope.orderItems}">
                <%--  如果订单非空的情况   --%>
                <c:forEach items="${sessionScope.orderItems}" var="order">
                    <tr>
                        <td>${order.name}</td>
                        <td>${order.count}</td>
                        <td>${order.price}</td>
                        <td>${order.totalPrice}</td>
                        <td>${order.orderId}</td>
                    </tr>
                </c:forEach>
            </c:if>
        </table>
    </div>
    <%--静态包含页脚内容--%>
    <%@include file="/pages/common/footer.jsp"%>
</body>
</html>

test 框架(多页面测试)

test 代码(多页面测试)

dzcp
index.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>电子产品</title>
    <%--静态包含 base标签,css样式,jquery文件 --%>
    <%@ include file="/pages/common/head.jsp"%>
</head>
<body>
电子产品
<a href="cartServlet?action=addItem">加入购物车</a>
</body>
</html>
fzyp
index.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>纺织用品</title>
    <%--静态包含 base标签,css样式,jquery文件 --%>
    <%@ include file="/pages/common/head.jsp"%>
</head>
<body>
纺织用品
<a href="index.jsp">返回首页</a>
</body>
</html>
index.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>书城首页</title>
    <%--静态包含 base标签,css样式,jquery文件 --%>
    <%@ include file="/pages/common/head.jsp"%>
    <script type="text/javascript">
        $(function (){
            //给加入购物车按钮绑定单击事件
            $("button.addToCart").click(function (){
                /**
                 * 在事件响应的function函数中,有一个this对象,这个this对象,是当前正在响应事件的dom对象
                 * @type {*|jQuery}
                 */
                var bookId= $(this).attr("bookId");
                location.href="http://localhost:8080/book/cartServlet?action=addItem&id="+bookId;
            });
        });
    </script>
</head>
<body>
    <div id="header">
        <img class="logo_ing"  alt=""  src="static/img/logo.gif">
        <span class= "wel_word">网上书城</span>
        <div>
            <%--  如果用户还没有登录,显示【登录和注册的菜单】--%>
            <c:if test="${empty sessionScope.user}">
                <a href="pages/user/login.jsp">登录</a>
                <a href="pages/user/regist.jsp">注册</a>
            </c:if>
            <%--  如果已经登录,显示登录之后的用户信息--%>
            <c:if test="${not empty sessionScope.user}">
                <span>欢迎<span class="um_span">${sessionScope.user.username}</span>光临尚硅谷书城</span>
                <a href="pages/order/order.jsp">我的订单</a>
                <a href="userServlet?action=logout">注销</a>
            </c:if>
            <a href="pages/cart/cart.jsp">购物车</a>
            <a href="pages/manager/manager.jsp">后台管理</a>
        </div>
        <div id="main">
            <div id="book">
                <div class="book_cond">
                    <form action="client/bookServlet" method="get">
                    <input type="hidden" name="action" value="pageByPrice">
                    价格:<input id="min" type="text"  name="min" value="${param.min}">元 -
                        <input id="max" type="text" name="max" value="${param.max}">元
                        <input type="submit" value="查询"/>
                    </form>
                </div>
                <div style="...">
                    <span>您的购物车中有3件商品</span>
                    <div>
                        您刚刚将<span style="...">时间简史</span>加入到了购物车中
                    </div>
                </div>
                <div>
                <c:forEach items="${requestScope.page.items}" var="book">
                    <div class="b_list">
                        <div class="img_div">
                            <img class="book_img" alt="${book.imgPath}"/>
                        </div>
                        <div class="book_info">
                            <div class="book_name">
                                <span class="sp1">书名:</span>
                                <span class="sp2">${book.name}</span>
                            </div>
                            <div class="book_author">
                                <span class="sp1">作者:</span>
                                <span class="sp2">${book.author}</span>
                            </div>
                            <div class= "book_price">
                                <span class="sp1">价格:</span>
                                <span class="sp2">¥${book.price}</span>
                            </div>
                            <div class="book_sales">
                                <span class="sp1">销量:</span>
                                <span class="sp2">${book.sales}</span>
                            </div>
                            <div class="book_amount">
                                <span class="sp1">库存:</span>
                                <span class="sp2">${book.stock}</span>
                            </div>
                            <div class="book_add">
                                <button bookId="${book.id}" class="addToCart">加入购物车:</button>
                        </div>
                        </div>
                    </div>
                </c:forEach>
                </div>
            </div>
            <%-- 静态包含分页条    --%>
          <%@include file="/pages/common/page_nav.jsp"%>
        </div>
    </div>
    <%--静态包含页脚内容--%>
    <%@include file="/pages/common/footer.jsp"%>
</body>
</html>

user 框架



user 代码

login.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>尚硅谷会员登录页面</title>
    <%--静态包含 base标签,css样式,jquery文件 --%>
    <%@ include file="/pages/common/head.jsp"%>
</head>
<body>
    <div id="login_header">
        <img class="logo_img" alt="" src="static/img/logo.gif" >
    </div>
        <div class="login banner">
            <div id="l_content">
                <span class="login_word">欢迎登录</span>
            </div>
            <div id="content">
                <div class="login_form">
                    <div class="login_box">
                         <div class="tit">
                            <h1>尚硅谷会员</h1>
                             <a href="pages/user/regist.jsp">立即注册</a>
                         </div>
                        <div class="msg_cont">
                            <b></b>
                            <span class="errorMsg">
<%--                                <%=request.getAttribute("msg")==null?"请输入用户名和密码":request.getAttribute("msg")%>&lt;%&ndash; 请输入用户名和密码&ndash;%&gt;--%>
                                ${empty requestScope.msg? "请输入用户名和密码" : requestScope.msg }
                            </span>
                        </div>
                        <div class="form">
                            <form action="userServlet" method="post">
                                <input type="hidden" name="action" value="login"/>
                                <label>用户名称:</label>
                                <input class="itxt" type="text" placeholder="请输入用户名"
                                       autocomplete="off" tabindex="1" name="username"
<%--                                        value="<%=request.getAttribute("username")==null?"":request.getAttribute("username")%>"/>--%>
                                        value="${requestScope.username}"/>
                                <br/>
                                <br/>
                                <label>用户密码:</label>
                                <input class="itxt" type="password" placeholder="请输入密码" autocomplete="off" tabindex="1" name="password"/>
                                <br/>
                                <br/>
                                <input type="submit" value="登录" id="sub_btn"/>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    <%--静态包含页脚内容--%>
    <%@ include file="/pages/common/footer.jsp" %>
</body>
</html>
login_success.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>尚硅谷会员登录</title>
    <style type="text/css">
        h1{
            text-align: center;
            margin-top: 200px;
        }
        h1 a {
            color: red;
        }
    </style>
</head>
<body>
<div id="header">
    <img class="logo_img" alt="" src="static/img/logo.gif">
    <%-- 静态包含登录成功之后的菜单--%>
   <%@ include file="/pages/common/login_sucess_menu.jsp"%>
    <div id="main">
        <h1>欢迎回来<a href="index.jsp">转到主页</a></h1>
    </div>
</div>
<%--静态包含页脚内容--%>
<%@include file="/pages/common/footer.jsp"%>
</body>
</html>
regist.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>尚硅谷会员注册页面</title>
    <%--静态包含 base标签,css样式,jquery文件 --%>
    <%@ include file="/pages/common/head.jsp"%>
    <script type="text/javascript">
        //页面加载完成之后
        $(function () {
            $("#username").blur(function (){
               //1 获取用户名
               var username=this.value;
               $.getJSON("http://localhost:8080/book/userServlet","action=ajaxExistsUsername&username="+username,function (data){
                   // console.log(data);
                   if (data.existsUsername){
                       $("span.errorMsg").text("用户名已存在!");
                   }else {
                       $("span.errorMsg").text("用户名可用!");
                   }
               });
            });
            //给验证码的图片,绑定单击事件
            $("#code_img").click(function (){
                //在事件响应的function函数中有一个this对象。这个this对象,是当前正在响应事件的dom对象
                //src表示验证码img标签的图片路径。它可读可写。
                // alert(this.src);
                this.src="${basePath}kaptcha.jpg?d="+new Date();
            });
            //给注册绑定单击事件
            $("#sub_btn").click(function () {
                //验证用户名:必须由字母,数字下划线组成,并且长度为5到12位
                //1获取用户名输入框里的内容
                var usernameText=$("#username").val();
                //2创建正则表达式对象
                var usernamePatt=/^\w{5,12}$/;
                //3使test方法验证
                if(!usernamePatt.test(usernameText)){
                    //4提示用户结果
                    $("span.errorMsg").text("用户名不合法!");
                    return false;
                }
                //验证密码:必须由字母,数字下划线组成,并且长度为5到12位
                //1获取用户名输入框里的内容
                var passwordText=$("#password").val();
                //2创建正则表达式对象
                var passwordPatt=/^\w{5,12}$/;
                //3使test方法验证
                if(!passwordPatt.test(passwordText)){
                    //4提示用户结果
                    $("span.errorMsg").text("密码不合法!");
                    return false;
                }
                //验证确认密码:和密码相同
                //1获取确认密码内容
                var repwdText=$("#repwd").val();
                //2和密码相比较
                if (repwdText!=passwordText){
                    //3提示用户
                    $("span.errorMsg").text("确认密码和密码不一致!");
                    return false;
                }
                //邮箱验证:xxxxx@xxx.com
                //1获取邮箱里的内容
                var emailText=$("#email").val();
                //2创建正则表达式对象
                var emailPatt=/^[a-z\d]+(\.[a-z\d]+)*@([\da-z](-[\da-z])?)+(\.{1,2}[a-z]+)+$/;
                //3使test方法验证
                if(!emailPatt.test(emailText)){
                    //4提示用户结果
                    $("span.errorMsg").text("邮箱格式不合法!");
                    return false;
                }
                //验证码现在只需要验证用户已输入。因为还没讲到服务器。验证码生成。
                var codeText=$("#code").val();
                //去掉验证码前后空格
                alert("去空格前["+codeText+"]");
                codeText=$.trim(codeText);
                alert("去空格后["+codeText+"]");
                if (codeText==null||codeText==""){
                    //提示用户结果
                    $("span.errorMsg").text("验证码不能为空");
                    return false;
                }
                $("span.errorMsg").text("");
            });
        });
    </script>
    <style type="text/css">
        .login_form {
            height: 420px;
            margin-top: 25px;
        }
    </style>
</head>
<body>
<div id="login_header">
    <img class="logo_img" alt="" src="static/img/logo.gif">
</div>
<div class="login_banner">
    <div id="l_content">
        <span class="login_word">欢迎注册</span>
    </div>
    <div id="content">
        <div class="login_form">
            <div class="login_box">
                <div class="tit">
                    <h1>注册尚硅谷会员</h1>
                    <span class="errorMsg">
<%--                        <%=request.getAttribute("msg")==null?"":request.getAttribute("msg")%>--%>
                        ${requestScope.msg}
                    </span>
                </div>
                <div class="form">
                    <form action="userServlet" method="post">
                        <input type="hidden" name="action" value="regist"/>
                        <label>用户名称:</label>
                        <input class="itxt" type="text" placeholder="请输入用户名"
<%--                               value="<%=request.getAttribute("username")==null?"":request.getAttribute("username")%>"--%>
                               value="${requestScope.username}"
                               autocomplete="off" tabindex="1" name="username" id="username"/>
                        <br/>
                        <br/>
                        <label>用户密码:</label>
                        <input class="itxt" type="password" placeholder="请输入密码"
                               autocomplete="off" tabindex="1" name="password" id="password"/>
                        <br/>
                        <br/>
                        <label>确认密码:</label>
                        <input class="itxt" type="password" placeholder="确认密码"
                               autocomplete="off" tabindex="1" name="repwd" id="repwd"/>
                        <br/>
                        <br/>
                        <label>电子邮件:</label>
                        <input class="itxt" type="text" placeholder="请输入邮箱地址"
<%--                               value="<%=request.getAttribute("email")==null?"":request.getAttribute("email")%>"--%>
                               value="${requestScope.email}"
                               autocomplete="off" tabindex="1" name="email" id="email"/>
                        <br/>
                        <br/>
                        <label>验证码:</label>
                        <input class="itxt" type="text" name="code" style="width: 80px;" id="code"/>
<%--                        <img alt="" src="kaptcha.jpg" style="float: right;margin-right: 40px;width: 100px;height: 28px;">--%>
                        <img id="code_img" alt="" src="kaptcha.jpg" style="width: 110px;height: 30px;">
                        <br/>
                        <br/>
                        <input type="submit" value="注册" id="sub_btn"/>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<%--静态包含页脚内容--%>
<%@include file="/pages/common/footer.jsp"%>
</body>
</html>
regist_success.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>尚硅谷会员注册页面</title>
    <%--静态包含 base标签,css样式,jquery文件 --%>
    <%@ include file="/pages/common/head.jsp"%>
    <style type="text/css">
    h1{
        text-align: center;
        margin-top: 200px;
    }
    h1 a {
        color: red;
    }
    </style>
</head>
<body>
    <div id="header">
        <img class="logo_img" alt=""  src="static/img/logo.gif">
        <span class="wel_word"></span>
        <%-- 静态包含登录成功之后的菜单--%>
        <%@ include file="/pages/common/login_sucess_menu.jsp"%>
    </div>
    <div id="main">
        <h1>注册成功!<a href="../../index.jsp">转到主页</a></h1>
    </div>
    <%--静态包含页脚内容--%>
    <%@include file="/pages/common/footer.jsp"%>
</body>
</html>

static 框架



static 代码

css

style.css

img

code.bmp

default.jpg

logo.gif


script

jquery.js

下载

WEB-INF 框架



WEB-INF 代码

lib

*.tld

说明 :taglib.jar 中

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    <servlet>
        <servlet-name>RegistServlet</servlet-name>
        <servlet-class>com.atguigu.web.RegistServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>RegistServlet</servlet-name>
        <url-pattern>/registServlet</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>LoginServlet</servlet-name>
        <servlet-class>com.atguigu.web.LoginServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>LoginServlet</servlet-name>
        <url-pattern>/loginServlet</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>UserServlet</servlet-name>
        <servlet-class>com.atguigu.web.UserServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>UserServlet</servlet-name>
        <url-pattern>/userServlet</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>BookServlet</servlet-name>
        <servlet-class>com.atguigu.web.BookServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>BookServlet</servlet-name>
        <url-pattern>/manager/bookServlet</url-pattern><!--  /manager方便管理  -->
    </servlet-mapping>
    <servlet>
        <servlet-name>ClientBookServlet</servlet-name>
        <servlet-class>com.atguigu.web.ClientBookServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>ClientBookServlet</servlet-name>
        <url-pattern>/client/bookServlet</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>KaptchaServlet</servlet-name>
        <servlet-class>com.google.code.kaptcha.servlet.KaptchaServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>KaptchaServlet</servlet-name>
        <url-pattern>/kaptcha.jpg</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>CartServlet</servlet-name>
        <servlet-class>com.atguigu.web.CartServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>CartServlet</servlet-name>
        <url-pattern>/cartServlet</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>OrderServlet</servlet-name>
        <servlet-class>com.atguigu.web.OrderServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>OrderServlet</servlet-name>
        <url-pattern>/orderServlet</url-pattern>
        <url-pattern>/pages/manager/orderServlet</url-pattern>
    </servlet-mapping>
    <filter>
        <filter-name>ManageFilter</filter-name>
        <filter-class>com.atguigu.filter.ManageFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>ManageFilter</filter-name>
        <url-pattern>/pages/manager/*</url-pattern>
        <url-pattern>/manager/bookServlet</url-pattern>
    </filter-mapping>
    <filter>
        <filter-name>TransactionFilter</filter-name>
        <filter-class>com.atguigu.filter.TransactionFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>TransactionFilter</filter-name>
        <!--  /*当前工程下所有请求      -->
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!-- error-page标签配置,服务器出错之后,自动跳转的页面   -->
    <error-page>
        <!--  error-code是错误类型      -->
        <error-code>500</error-code>
        <!-- location标签表示,要跳转的页面路径-->
        <location>/pages/error/error500.jsp</location>
    </error-page>
    <!-- error-page标签配置,服务器出错之后,自动跳转的页面   -->
    <error-page>
        <!--  error-code是错误类型      -->
        <error-code>404</error-code>
        <!-- location标签表示,要跳转的页面路径-->
        <location>/pages/error/error404.jsp</location>
    </error-page>
    <jsp-config>
        <taglib>
            <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
            <taglib-location>/WEB-INF/c.tld</taglib-location>
        </taglib>
        <taglib>
            <taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
            <taglib-location>/WEB-INF/fmt.tld</taglib-location>
        </taglib>
        <taglib>
            <taglib-uri>http://java.sun.com/jsp/jstl/sql</taglib-uri>
            <taglib-location>/WEB-INF/sql.tld</taglib-location>
        </taglib>
        <taglib>
            <taglib-uri>http://java.sun.com/jsp/jstl/xml</taglib-uri>
            <taglib-location>/WEB-INF/x.tld</taglib-location>
        </taglib>
        <taglib>
            <taglib-uri>http://java.sun.com/jsp/jstl/functions</taglib-uri>
            <taglib-location>/WEB-INF/fn.tld</taglib-location>
        </taglib>
    </jsp-config>
</web-app>

index.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--只负责请求转发--%>
<jsp:forward page="/client/bookServlet?action=page"></jsp:forward> 
相关文章
|
4月前
|
JavaScript Java 测试技术
基于SpringBoot+Vue的贵工程学生宿舍管理系统的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue的贵工程学生宿舍管理系统的详细设计和实现(源码+lw+部署文档+讲解等)
31 0
|
6月前
|
Java BI 数据库
基于SSM框架实现面向小微企业的简历管理系统企业简历管理系统(分前后台spring+springmvc+mybatis+maven+jsp+css+echarts)
基于SSM框架实现面向小微企业的简历管理系统企业简历管理系统(分前后台spring+springmvc+mybatis+maven+jsp+css+echarts)
|
6月前
|
JavaScript Java 测试技术
基于SpringBoot+Vue+uniapp的金旗帜文化培训学校网站的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue+uniapp的金旗帜文化培训学校网站的详细设计和实现(源码+lw+部署文档+讲解等)
|
6月前
|
JavaScript Java 测试技术
基于SpringBoot+Vue的桂林旅游景点导游平台附带文章和源代码
基于SpringBoot+Vue的桂林旅游景点导游平台附带文章和源代码
51 1
|
数据库
书城项目第六、七阶段2
书城项目第六、七阶段2
48 1
|
前端开发 JavaScript Java
书城项目第三阶段及其源码2
书城项目第三阶段及其源码2
45 0
书城项目第六、七阶段1
书城项目第六、七阶段1
45 0
|
前端开发 Java 程序员
书城项目第五阶段-图书模块1
书城项目第五阶段-图书模块1
86 0
|
前端开发 Java 关系型数据库
estore网上书城项目分享
estore网上书城项目分享
100 0
书城项目第五阶段-图书模块2
书城项目第五阶段-图书模块2
32 0