购物小网站(下)

在这里插入图片描述
图片素材
提取码:v7rx
在这里插入图片描述

/* 样式 */
body {
    margin: 0px;
    text-align: center;
    background: url("../images/frontBack.jpg") no-repeat;
    background-size: 100%
}

table {
    margin: 0 auto;
    font-size: 14px;
    color: #333333;
    border-width: 1px;
    border-color: khaki;
    border-collapse: collapse;
}

table th {
    border-width: 1px;
    padding: 8px;
    border-style: solid;
    border-color: gainsboro;
    background-color: honeydew;
}

table td {
    border-width: 1px;
    padding: 8px;
    border-style: solid;
    border-color: gainsboro;
    background-color: #ffffff;
}

/*登录页面样式*/
.login {
    width: 400px;
    height: 340px;
    background-color: honeydew;
    border: solid 2px darkgrey;
    left: 50%;
    top: 50%;
    position: absolute;
    margin: -170px 0 0 -200px;
}

.login .websiteTitle, .title {
    border: solid 1px floralwhite;
}

/*注册页面样式*/
.register {
    width: 400px;
    height: 350px;
    background-color: honeydew;
    border: solid 2px darkgrey;
    left: 50%;
    top: 50%;
    position: absolute;
    margin: -175px 0 0 -200px;
}

/*显示类别页面样式*/
.showCategory {
    width: 400px;
    height: 350px;
    background-color: honeydew;
    border: solid 2px darkgrey;
    left: 50%;
    top: 50%;
    position: absolute;
    margin: -150px 0 0 -200px;
}

/*生成订单页面样式*/
.makeOrder {
    width: 400px;
    height: 400px;
    background-color: honeydew;
    border: solid 2px darkgrey;
    left: 50%;
    top: 50%;
    position: absolute;
    margin: -200px 0 0 -200px;
}

/*显示订单页面样式*/
.showOrder {
    width: 400px;
    height: 400px;
    background-color: honeydew;
    border: solid 2px darkgrey;
    left: 50%;
    top: 50%;
    position: absolute;
    margin: -200px 0 0 -200px;
}

在web目录里创建scripts子目录,在里面创建check.js文件:
在这里插入图片描述

/**
 * 检验登录表单
 *
 * @returns {Boolean}
 */
function checkLoginForm() {
    var username = document.getElementById("username");
    var password = document.getElementById("password");
    if (username.value == "") {
        alert("用户名不能为空!");
        username.focus();
        return false;
    }
    if (password.value == "") {
        alert("密码不能为空!");
        password.focus();
        return false;
    }
    return true;
}

/**
 * 检验注册表单
 *
 * @returns {Boolean}
 */
function checkRegisterForm() {
    var username = document.getElementById("username");
    var password = document.getElementById("password");
    var telephone = document.getElementById("telephone");
    if (username.value == "") {
        alert("用户名不能为空!");
        username.focus();
        return false;
    }
    if (password.value == "") {
        alert("密码不能为空!");
        password.focus();
        return false;
    }

    var pattern = "/^(13[0-9]|14[0-9]|15[0-9]|18[0-9])\d{8}$/";
    if (!pattern.exec(telephone)) {
        alert("非法手机号!");
        telephone.focus();
        return false;
    }
    return true;
}

在WEB-INF\lib目录里添加支持jstl的jar包:
jar包下载地址:http://tomcat.apache.org/taglibs/standard/
在这里插入图片描述
在这里插入图片描述

/**
 * 检验登录表单
 *
 * @returns {Boolean}
 */
function checkLoginForm() {
    var username = document.getElementById("username");
    var password = document.getElementById("password");
    if (username.value == "") {
        alert("用户名不能为空!");
        username.focus();
        return false;
    }
    if (password.value == "") {
        alert("密码不能为空!");
        password.focus();
        return false;
    }
    return true;
}

/**
 * 检验注册表单
 *
 * @returns {Boolean}
 */
function checkRegisterForm() {
    var username = document.getElementById("username");
    var password = document.getElementById("password");
    var telephone = document.getElementById("telephone");
    if (username.value == "") {
        alert("用户名不能为空!");
        username.focus();
        return false;
    }
    if (password.value == "") {
        alert("密码不能为空!");
        password.focus();
        return false;
    }

    var pattern = "/^(13[0-9]|14[0-9]|15[0-9]|18[0-9])\d{8}$/";
    if (!pattern.exec(telephone)) {
        alert("非法手机号!");
        telephone.focus();
        return false;
    }
    return true;
}

在web.xml文件里将login.jsp设置为首页文件:
在这里插入图片描述

<?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">
    <welcome-file-list>
        <welcome-file>login.jsp</welcome-file>
    </welcome-file-list>

</web-app>

重启服务器:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
输入管理员用户名与密码:admin,12345
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
界面部分:
在这里插入图片描述
在这里插入图片描述

<%--
  Created by IntelliJ IDEA.
  User: 
  Date: 2019/12/18
  Time: 8:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:set var="path" value="${pageContext.request.contextPath}"/>
<c:set var="basePath"
       value="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${path}/"/>
<!DOCTYPE html>
<html>
<head>
    <title>用户注册</title>
    <base href="${basePath}">
    <link href="css/main.css" rel="stylesheet" type="text/css"/>
    <script src="scripts/check.js" type="text/javascript"></script>
</head>
<body>

<div class="register">
    <div class="websiteTitle">
        <h1>西蒙购物网</h1>
    </div>
    <div class="title">
        <h3>用户注册</h3>
    </div>
    <div class="main">
        <form action="register" method="post">
            <table>
                <tr>
                    <td>账号</td>
                    <td><input id="username" type="text" name="username"/></td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td><input id="password" type="password" name="password"/></td>
                </tr>
                <tr>
                    <td align="center">电话</td>
                    <td><input id="telephone" type="text" name="telephone"/></td>
                </tr>
                <tr align="center">
                    <td colspan="2">
                        <input type="submit" value="注册" onclick="return checkRegisterForm();"/>
                        <input type="reset" value="重置"/></td>
                </tr>
            </table>
        </form>
    </div>
    <div class="footer">
        <p><a href="login.jsp">切换到登录页面</a></p>
    </div>
</div>

<c:if test="${registerMsg!=null}">
    <script type="text/javascript">alert("${registerMsg}")</script>
    <c:set var="registerMsg" value=""/>
</c:if>
</body>
</html>

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

<%--
  Created by IntelliJ IDEA.
  User: 杨华
  Date: 2019/12/18
  Time: 8:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:set var="path" value="${pageContext.request.contextPath}"/>
<c:set var="basePath"
       value="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${path}/"/>
<!DOCTYPE html>
<html>
<head>
    <title>显示商品类别</title>
    <base href="${basePath}">
    <link href="css/main.css" rel="stylesheet" type="text/css"/>
</head>
<body>

<div class="showCategory">
    <div class="websiteTitle">
        <h1>西蒙购物网</h1>
    </div>
    <div>
        登录用户:<span style="color: red;">${username}</span>
        <c:forEach var="i" begin="1" end="5">
        </c:forEach>
        <a href="logout">注销</a>
    </div>
    <div class="title">
        <h3>商品类别</h3>
    </div>
    <div class="main">
        <table>
            <tr>
                <th>类别编号</th>
                <th>商品类别</th>
            </tr>
            <c:forEach var="category" items="${categories}">
                <tr align='center'>
                    <td>${category.id}</td>
                    <td width="150">
                        <a href="showProduct?categoryId=${category.id}">${category.name}</a>
                    </td>
                </tr>
            </c:forEach>
        </table>
    </div>
</div>
</body>
</html>


在这里插入图片描述
在这里插入图片描述

<%--
  Created by IntelliJ IDEA.
  User: 杨华
  Date: 2019/12/18
  Time: 8:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<c:set var="path" value="${pageContext.request.contextPath}"/>
<c:set var="basePath"
       value="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${path}/"/>
<!DOCTYPE html>
<html>
<head>
    <title>显示商品信息</title>
    <base href="${basePath}">
    <link href="css/main.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<h1>西蒙购物网</h1>
<hr width="700px">
登录用户:<span style="color: red;">${username}</span>
<c:forEach var="i" begin="1" end="5">
</c:forEach>
<a href="logout">注销</a></td>
<hr width="700px">
欢迎选购【<span style="color: blue; font-weight: bold;">${categoryName}</span>】类商品
<hr width="700px">
<table border="0">
    <c:forEach varStatus="status" var="product" items="${products}">
        <c:if test="${status.count%5==0}">
            <tr>
        </c:if>
        <td>
            <table border="0">
                <tr><img src="images/product${product.id}.jpg" width="60px" height="60px"></tr>
                <tr>
                    <td><b>商品编号:</b></td>
                    <td>${product.id}</td>
                </tr>
                <tr>
                    <td><b>商品名称:</b></td>
                    <td>${product.name}</td>
                </tr>
                <tr>
                    <td><b>销售价格:</b></td>
                    <td>${product.price}</td>
                </tr>
                <tr>
                    <td><b>上架时间:</b></td>
                    <td><fmt:formatDate value="${product.addTime}" pattern="yyyy-MM-dd"/></td>
                </tr>
                <tr>
                    <td><b>用户操作:</b></td>
                    <td><a href="operateCart?id=${product.id}&operation=add">加入购物车</a></td>
                </tr>
            </table>
        </td>
        <c:if test="${status.count%4==0}">
            </tr>
        </c:if>
    </c:forEach>
</table>
<hr width="700px">
<a href="showCategory">返回商品类别页面</a>
<hr width="700px">
<jsp:include page="showCart.jsp"/>
</body>
</html>


在这里插入图片描述

<%--
  Created by IntelliJ IDEA.
  User: 杨华
  Date: 2019/12/18
  Time: 8:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<c:set var="path" value="${pageContext.request.contextPath}"/>
<c:set var="basePath"
       value="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${path}/"/>
<!DOCTYPE html>
<html>
<head>
    <title>显示购物车</title>
    <base href="${basePath}">
</head>
<body>
<h3>${username}的购物车</h3>
<table>
    <tr>
        <th>商品编号</th>
        <th>商品名称</th>
        <th>销售价格</th>
        <th>购买数量</th>
        <th>合计金额</th>
        <th>用户操作</th>
    </tr>
    <c:forEach var="shoppingItem" items="${shoppingTable}">
        <tr>
            <td>${shoppingItem.id}</td>
            <td>${shoppingItem.name}</td>
            <td>¥${shoppingItem.price}</td>
            <td>${shoppingItem.amount}</td>
            <td>¥${shoppingItem.sum}</td>
            <td><a href="operateCart?id=${shoppingItem.id}&operation=delete">删除</a></td>
        </tr>
    </c:forEach>
    <tr>
        <th>总金额</th>
        <td></td>
        <td></td>
        <td></td>
        <c:choose>
            <c:when test="${totalPrice==null}">
                <th style="color: red">¥0.00</th>
            </c:when>
            <c:otherwise>
                <th style="color: red">¥${totalPrice}</th>
            </c:otherwise>
        </c:choose>
        <td></td>
    </tr>
</table>
<hr width="800px">
<c:choose>
    <c:when test="${totalPrice==null}">
        <a href="frontend/makeOrder.jsp?totalPrice=0.00">生成订单</a>
    </c:when>
    <c:otherwise>
        <a href="frontend/makeOrder.jsp?totalPrice=${totalPrice}">生成订单</a>
    </c:otherwise>
</c:choose>
<c:if test="${orderMsg!=null}">
    <script type="text/javascript">alert("${orderMsg}")</script>
    <c:remove var="orderMsg"/>
</c:if>
</body>
</html>


在这里插入图片描述

<%--
  Created by IntelliJ IDEA.
  User: 杨华
  Date: 2019/12/18
  Time: 8:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:set var="path" value="${pageContext.request.contextPath}"/>
<c:set var="basePath"
       value="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${path}/"/>
<!DOCTYPE html>
<html>
<head>
    <title>生成订单</title>
    <base href="${basePath}">
    <link href="css/main.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="makeOrder">
    <div class="websiteTitle">
        <h1>西蒙购物网</h1>
    </div>
    <div>
        登录用户:<span style="color: red;">${username}</span>
        <c:forEach var="i" begin="1" end="5">

        </c:forEach>
        <a href="logout">注销</a>
    </div>
    <div class="title">
        <h3>生成订单</h3>
    </div>
    <div class="main">
        <form action="makeOrder" method="post">
            <table>
                <tr>
                    <td>用户名</td>
                    <td><input type="text" name="username" readonly="readonly"
                               value="${username}"/></td>
                </tr>
                <tr>
                    <td>联系电话</td>
                    <td><input type="text" name="telephone"/></td>
                </tr>
                <tr>
                    <td>总金额</td>
                    <td><input type="text" name="totalPrice" readonly="readonly"
                               value="${totalPrice}"/></td>
                </tr>
                <tr>
                    <td>送货地址</td>
                    <td><input type="text" name="deliveryAddress"/></td>
                </tr>
                <tr align="center">
                    <td colspan="2"><input type="submit" value="生成订单"/> <input
                            type="reset" value="重置"/></td>
                </tr>
            </table>
        </form>
    </div>
    <div class="footer">
        <p><a href="showCategory">返回商品类别页面</a></p>
    </div>
</div>
</body>
</html>


在这里插入图片描述

<%--
  Created by IntelliJ IDEA.
  User: 杨华
  Date: 2019/12/18
  Time: 8:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:set var="path" value="${pageContext.request.contextPath}"/>
<c:set var="basePath"
       value="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${path}/"/>
<!DOCTYPE html>
<html>
<head>
    <title>显示订单</title>
    <base href="${basePath}">
    <link href="css/main.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="showOrder">
    <div class="websiteTitle">
        <h1>西蒙购物网</h1>
    </div>
    <div>
        登录用户:<span style="color: red;">${username}</span>
        <c:forEach var="i" begin="1" end="5">
        </c:forEach>
        <a href="logout">注销</a>
    </div>
    <div class="title">
        <h3>生成订单</h3>
    </div>
    <div class="main">
        <table border="1" cellspacing="0">
            <tr>
                <th>订单编号</th>
                <td>${lastOrder.id}</td>
            </tr>
            <tr>
                <th>用户名</th>
                <td>${lastOrder.username}</td>
            </tr>
            <tr>
                <th>联系电话</th>
                <td>${lastOrder.telephone}</td>
            </tr>
            <tr>
                <th>总金额</th>
                <td>${lastOrder.totalPrice}</td>
            </tr>
            <tr>
                <th>送货地址</th>
                <td>${lastOrder.deliveryAddress}</td>
            </tr>
        </table>
    </div>
    <div class="footer">
        <p><a href="pay" οnclick="alert('${lastOrder.username},支付成功!');">支付</a></p>
    </div>
</div>
</body>
</html>


在这里插入图片描述
后台管理页面
在这里插入图片描述
在这里插入图片描述

<%--
  Created by IntelliJ IDEA.
  User: 杨华
  Date: 2019/12/18
  Time: 8:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<c:set var="path" value="${pageContext.request.contextPath}"/>
<c:set var="basePath"
       value="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${path}/"/>
<!DOCTYPE html>
<html>
<head>
    <title>后台管理左面板</title>
    <base href="${basePath}">
    <link rel="stylesheet" type="text/css">
    <script type="text/javascript">
        function show(id) {
            var obj = document.getElementById('c_' + id);
            if (obj.style.display == 'block') {
                obj.style.display = 'none';
            } else {
                obj.style.display = 'block';
            }
        }
    </script>
</head>

<body>
<table cellSpacing=0 cellPadding=0 width='100%' border=0>
    <tbody>
    <tr>
        <td class=catemenu> <a
                style='CURSOR: pointer' οnclick=show(1)><img src="images/folder.png">用户管理</a>
        </td>
    </tr>
    <tbody id=c_1>
    <tr>
        <td class=bar2 height=20>  <img src="images/file.png"> <a href="showUser" target="main_frame">查看用户</a></td>
    </tr>
    <tr>
        <td class=bar2 height=20>  <img src="images/file.png"> <a href="backend/todo.jsp" target="main_frame">添加用户</a>
        </td>
    </tr>
    <tr>
        <td class=bar2 height=20>  <img src="images/file.png"> <a href="backend/todo.jsp" target="main_frame">更新用户</a>
        </td>
    </tr>
    <tr>
        <td class=bar2 height=20>  <img src="images/file.png"> <a href="backend/todo.jsp" target="main_frame">删除用户</a>
        </td>
    </tr>
    </tbody>

    <tbody>
    <tr>
        <td class=catemenu> <a
                style='CURSOR: pointer' οnclick=show(2)><img src="images/folder.png">
            类别管理</a></td>
    </tr>
    <tbody id=c_2 style='DISPLAY: none'>
    <tr>
        <td class=bar2 height=20>  <img src="images/file.png"> <a href="backend/todo.jsp" target="main_frame">查看类别</a>
        </td>
    </tr>
    <tr>
        <td class=bar2 height=20>  <img src="images/file.png"> <a href="backend/todo.jsp" target="main_frame">添加类别</a>
        </td>
    </tr>
    <tr>
        <td class=bar2 height=20>  <img src="images/file.png"> <a href="backend/todo.jsp" target="main_frame">更新类别</a>
        </td>
    </tr>
    <tr>
        <td class=bar2 height=20>  <img src="images/file.png"> <a href="backend/todo.jsp" target="main_frame">删除类别</a>
        </td>
    </tr>
    </tbody>

    <tbody>
    <tr>
        <td class=catemenu> <a
                style='CURSOR: pointer' οnclick=show(3)><img src="images/folder.png">
            商品管理</a></td>
    </tr>
    <tbody id=c_3 style='DISPLAY: none'>
    <tr>
        <td class=bar2 height=20>  <img src="images/file.png"> <a href="backend/todo.jsp" target="main_frame">查看商品</a>
        </td>
    </tr>
    <tr>
        <td class=bar2 height=20>  <img src="images/file.png"> <a href="backend/todo.jsp" target="main_frame">添加商品</a>
        </td>
    </tr>
    <tr>
        <td class=bar2 height=20>  <img src="images/file.png"> <a href="backend/todo.jsp" target="main_frame">更新商品</a>
        </td>
    </tr>
    <tr>
        <td class=bar2 height=20>  <img src="images/file.png"> <a href="backend/todo.jsp" target="main_frame">删除商品</a>
        </td>
    </tr>
    </tbody>

    <tbody>
    <tr>
        <td class=catemenu> <a
                style='CURSOR: pointer' οnclick=show(4)><img src="images/folder.png">
            订单管理</a></td>
    </tr>
    <tbody id=c_4 style='DISPLAY: none'>
    <tr>
        <td class=bar2 height=20>  <img src="images/file.png"> <a href="backend/todo.jsp" target="main_frame">查看订单</a>
        </td>
    </tr>
    <tr>
        <td class=bar2 height=20>  <img src="images/file.png"> <a href="backend/todo.jsp" target="main_frame">删除订单</a>
        </td>
    </tr>
    </tbody>
</table>
</body>
</html>



在这里插入图片描述

<%--
  Created by IntelliJ IDEA.
  User: 杨华
  Date: 2019/12/18
  Time: 8:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:set var="path" value="${pageContext.request.contextPath}"/>
<c:set var="basePath"
       value="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${path}/"/>
<!DOCTYPE html>
<html>
<head>
    <title>后台管理主面板</title>
    <base href="${basePath}">
</head>
<body>
<img src="images/mainBack.gif" width="100%" height="100%"/>
</body>
</html>


在这里插入图片描述

<%--
  Created by IntelliJ IDEA.
  User: 杨华
  Date: 2019/12/18
  Time: 8:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:set var="path" value="${pageContext.request.contextPath}"/>
<c:set var="basePath"
       value="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${path}/"/>
<!DOCTYPE html>
<html>
<head>
    <title>后台管理顶面板</title>
    <base href="${basePath}">
</head>
<body style="margin:0px">
<img src="images/title.png" width="100%" height="100%">
</body>
</html>


在这里插入图片描述

<%--
  Created by IntelliJ IDEA.
  User: 杨华
  Date: 2019/12/18
  Time: 8:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<c:set var="path" value="${pageContext.request.contextPath}"/>
<c:set var="basePath"
       value="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${path}/"/>
<!DOCTYPE html>
<html>
<head>
    <title>显示用户信息</title>
    <base href="${basePath}">
    <link href="css/main.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<hr>
<table width="90%" border="0px">
    <tr>
        <td align="left">登录用户:<span style="color: red;">${username}</span></td>
        <td align="right"><a href="user/logout" target="_parent">注销</a></td>
    </tr>
</table>
<hr>
<h3>用户列表</h3>
<hr>
<table border="1" width="90%" cellspacing="0">
    <tr>
        <th>编号</th>
        <th>用户名</th>
        <th>密码</th>
        <th>电话</th>
        <th>注册时间</th>
        <th>权限</th>
    </tr>
    <c:forEach var="user" items="${users}">
        <tr align="center">
            <td>${user.id}</td>
            <td>${user.username}</td>
            <td>${user.password}</td>
            <td>${user.telephone}</td>
            <td><fmt:formatDate value="${user.registerTime}" pattern="yyyy-MM-dd hh:mm:ss"/></td>
            <td>
                <c:choose>
                    <c:when test="${user.popedom==0}">
                        管理员
                    </c:when>
                    <c:otherwise>
                        普通用户
                    </c:otherwise>
                </c:choose>
            </td>
        </tr>
    </c:forEach>
</table>
<hr>
</body>
</html>


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
我们可以利用JSP(Java服务器页面)和Servlet来开发一个小型的购物网站。首先,我们可以使用JSP来设计网站的页面,包括主页、商品列表页、购物车页面和订单页面等。在这些页面中,我们可以使用JSP标签来动态生成网页内容,例如显示商品信息、用户信息和购物车中的商品等。同时,JSP还可以和JavaBean结合,从数据库中获取商品信息并展示在页面上。 另外,我们还可以利用Servlet来处理用户的请求和数据的传输。Servlet可以接收用户提交的表单数据,并对数据进行处理,例如将商品添加到购物车、更新购物车中商品的数量、生成订单等。同时,Servlet还可以和数据库进行交互,从数据库中查询商品信息、用户信息和订单信息,并将数据返回给JSP页面进行展示。 在开发过程中,我们可以使用MVC(模型-视图-控制器)的设计模式,将业务逻辑、数据逻辑和页面展示分离开来,保持代码的清晰和易于维护。同时,我们还可以使用JavaWeb框架如Spring MVC来简化开发流程,提高开发效率。 综合来说,通过JSP和Servlet的组合,我们可以开发一个简单、易用的小型购物网站,为用户提供商品浏览、购物车管理和订单生成等功能。同时,我们还可以利用数据库来存储商品信息、用户信息和订单信息,实现数据的持久化。通过不断地优化和完善,我们可以打造一个功能完备、用户体验良好的小型购物网站

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值