IDEA+Java+JSP+Mysql+Tomcat实现Web图书管理系统(上)

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS PostgreSQL,集群系列 2核4GB
简介: IDEA+Java+JSP+Mysql+Tomcat实现Web图书管理系统

一、系统介绍


软件环境

Operating System:Windows10

IDEA:2018.2

Java:jdk1.8

Mysql:8.0.13

Tomcat:7.0.85


该图书管理系统实现了用户注册与登录功能,实现了实现了图书列表展示,购物车简单的功能。后台表只有三张,一张是user表,存储的是用户的信息,一张是book表,存储的是图书的信息,另外一张是card表,用来存储某个用户对应的购物车的信息。


下面是整个整个工程的截图


20200601211600884.jpg

20200601211621668.jpg


二、系统展示


1.登录界面


20200601211704473.jpg


2.注册界面


20200601211730113.jpg


3.图书列表界面


20200601211816203.jpg


4.图书详情界面


20200601211847199.jpg


5.购物车界面


20200601211921194.jpg


三、部分代码


1.前端


book.jsp

<%--
  Created by IntelliJ IDEA.
  User: shuijianshiqing
  Date: 2020/5/24
  Time: 10:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ page import="java.util.List" %>
<%@ page import="com.sjsq.po.Book" %>
<%@ page import="com.sjsq.service.impl.BookServiceImpl" %>
<%@ page import="com.sjsq.po.User" %>
<!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>查看图书</title>
    <style type="text/css">
        h1{
            text-align: center;
        }
        #before{
            text-align: center;
        }
        #head{
            background: #eeeeee;height: 80px;
        }
        #headLink{
            font-size: 20px;
        }
        #headWelLink{
            font-size: 20px;
        }
    </style>
</head>
<body>
    <%--头部信息--%>
    <%
        User user =(User)session.getAttribute("user");
        if(user == null){
            response.sendRedirect("login.jsp");
        }else {
    %>
    <div id="head">
        <table width="100%">
            <td id="headWelLink">欢迎您:<%=user.getName()%></td>
            <td align="right" id="headLink">
                <a href="cart.jsp">我的购物车</a>
                <a href="logout.jsp">安全退出</a>
            </td>
        </table>
    </div>
    <%
        }
    %>
    <%--图书信息--%>
    <%
        Book book = new Book();
        BookServiceImpl service = new BookServiceImpl();
        List<Book> list = service.select(book);
    %>
    <h1>图书列表</h1>
    <div id="before">
        <a href="javascript: window.history.go(-1)">返回上一级</a>
    </div>
    <table align="center" cellpadding="10" cellspacing="10">
        <tr bgcolor="green">
            <td>编号</td>
            <td>书名</td>
            <td>价格</td>
            <td>作者</td>
            <td>封皮</td>
            <td>出版社</td>
        </tr>
        <%
            String bg = null;
            for (int i = 0;i<list.size();i++){
                Book b =list.get(i);
                if(i%2 == 0){
                    bg = "pink";
                }else{
                    bg = "yellow";
                }
        %>
        <tr bgcolor="<%=bg%>">
            <td><%=b.getBookid()%></td>
            <td><a href="doInfo.jsp?bookid=<%=b.getBookid()%>"><%=b.getBookname()%></a></td>
            <td><%=b.getPrice() %></td>
            <td><%=b.getAuthor() %></td>
            <td><%=b.getPicture() %></td>
            <td><%=b.getPublish() %></td>
        </tr>
        <%
            }
        %>
    </table>
</body>
</html>

cart.jsp

<%--
  Created by IntelliJ IDEA.
  User: shuijianshiqing
  Date: 2020/5/31
  Time: 10:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.sjsq.po.User" %>
<%@ page import="com.sjsq.po.Card" %>
<%@ page import="com.sjsq.service.CardService" %>
<%@ page import="com.sjsq.service.impl.CardServiceImpl" %>
<%@ page import="java.util.List" %>
<%@ page import="com.sjsq.dao.BookDao" %>
<%@ page import="com.sjsq.dao.impl.BookDaoImpl" %>
<html>
<head>
    <title>购物车信息</title>
    <style type="text/css">
        h1{
            text-align: center;
        }
        #before{
            text-align: center;
        }
        #head{
            background: #eeeeee;height: 80px;
        }
        #headLink{
            font-size: 20px;
        }
        #headWelLink{
            font-size: 20px;
        }
    </style>
</head>
<body>
    <%--头部信息--%>
    <%
        User user =(User)session.getAttribute("user");
        if(user == null){
            response.sendRedirect("login.jsp");
        }else {
    %>
    <div id="head">
        <table width="100%">
            <td id="headWelLink">欢迎您:<%=user.getName()%></td>
            <td align="right" id="headLink">
                <a href="cart.jsp">我的购物车</a>
                <a href="logout.jsp">安全退出</a>
            </td>
        </table>
    </div>
    <%
        }
    %>
    <%--图书信息--%>
    <%
        CardService service = new CardServiceImpl();
        List<Card> list = service.getCard(user.getId());
        BookDao dao = new BookDaoImpl();
        Double totalPrice = 0D;
        Double bookPrice = 0D;
    %>
    <h1>购物车图书</h1>
    <div id="before">
        <a href="javascript: window.history.go(-1)">返回上一级</a>
    </div>
    <table align="center" cellpadding="10" cellspacing="10">
        <tr bgcolor="green">
            <td>姓名</td>
            <td>图书序号</td>
            <td>书名</td>
            <td>数量</td>
            <td>价格小计</td>
        </tr>
        <%
            for (int i = 0;i<list.size();i++){
            Card card = list.get(i);
            String bookName = dao.getBook(card.getBookid()).getBookname();
            bookPrice = dao.getBook(card.getBookid()).getPrice()*card.getBooknum();
            totalPrice = bookPrice + totalPrice;
        %>
        <tr bgcolor="#ffdead">
            <td><%=card.getUsername() %></td>
            <td><%=card.getBookid() %></td>
            <td><%=bookName %></td>
            <td><%=card.getBooknum() %></td>
            <td><%=bookPrice%></td>
        </tr>
        <%
            }
        %>
        <tr>
            <td colspan="4" align="right" bgcolor="#6495ed">价格总计</td>
            <td bgcolor="#6495ed"><%=totalPrice %></td>
        </tr>
    </table>
    <div style="text-align:center;font-size:20px;margin-top:20px;">
        <a href="book.jsp">继续购买图书</a>
        <a href="login.jsp">登陆页面</a>
    </div>
</body>
</html>

detail.jsp

<%--
  Created by IntelliJ IDEA.
  User: shuijianshiqing
  Date: 2020/5/24
  Time: 10:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ page import="com.sjsq.po.Book" %>
<%@ page import="com.sjsq.po.User" %>
<%
    // 获取绝对路径路径 ,开发项目一定要使用绝对路径,不然肯定出错
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":"
            + request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath %>" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>图书详情</title>
    <style type="text/css">
        h1{
            text-align: center;
        }
        a{
            text-align:center;font-size: 24px;text-decoration: none;
        }
        a:hover{
            text-decoration: underline;font-size: 20px;
        }
        #before{
            text-align: center;
        }
        #head{
            background: #eeeeee;height: 80px;
        }
        #headLink{
            font-size: 20px;
        }
        #headWelLink{
            font-size: 20px;
        }
    </style>
</head>
<body>
    <%--头部信息--%>
    <%
        User user =(User)session.getAttribute("user");
        if(user == null){
            response.sendRedirect("login.jsp");
        }else {
    %>
    <div id="head">
        <table width="100%">
            <td id="headWelLink">欢迎您:<%=user.getName()%></td>
            <td align="right" id="headLink">
                <a href="cart.jsp">我的购物车</a>
                <a href="logout.jsp">安全退出</a>
            </td>
        </table>
    </div>
    <%
        }
    %>
    <h1>图书详情</h1>
    <div id="before">
        <a href="javascript: window.history.go(-1)">返回上一级</a>
    </div>
    <%
        Book book = (Book)session.getAttribute("book");
    %>
    <table align="center" cellpadding="20" cellspacing="20">
        <tr style="font-size: 20px">
            <td>图书编号</td>
            <td>图书名称</td>
            <td>图书价格</td>
            <td>图书作者</td>
            <td>图书封皮</td>
            <td>图书出版社</td>
        </tr>
        <tr>
            <td><%=book.getBookid()%></td>
            <td><%=book.getBookname()%></td>
            <td><%=book.getPrice()%></td>
            <td><%=book.getAuthor()%></td>
            <td><%=book.getPicture()%></td>
            <td><%=book.getPublish()%></td>
        </tr>
        <tr>
            <td colspan="3"></td>
            <td></td>
            <td colspan="2"></td>
        </tr>
    </table>
    <div style="text-align:center;font-size: 36px;">
        <a href="doCart.jsp">添加到购物车</a>
        <a href="book.jsp">图书列表</a>
    </div>
</body>
</html>

doCart.jsp

<%--
  Created by IntelliJ IDEA.
  User: shuijianshiqing
  Date: 2020/5/31
  Time: 10:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ page import="com.sjsq.po.Book" %>
<%@ page import="com.sjsq.po.User" %>
<%@ page import="com.sjsq.service.CardService" %>
<%@ page import="com.sjsq.service.impl.CardServiceImpl" %>
<html>
<head>
    <title>处理购物车</title>
</head>
<body>
    <%-- 处理购物车 --%>
    <%
        // 获取用户的信息
        User user =(User)session.getAttribute("user");
        // 获取书籍的信息
        Book book = (Book)session.getAttribute("book");
        // 定义购物车服务
        CardService service = new CardServiceImpl();
        // 获取图书数量且加1
        Integer booknum = service.getBookNum(book) + 1;
        // 执行添加购物车操作
        boolean flag = service.addCard(user,book,booknum);
        if(flag){
            // 添加成功返回到购物车页面
            response.sendRedirect("cart.jsp");
        }else{
            //
            response.sendRedirect("doCartFail.jsp");
        }
    %>
</body>
</html>

doCartFail.jsp

<%--
  Created by IntelliJ IDEA.
  User: shuijianshiqing
  Date: 2020/5/31
  Time: 11:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>添加失败</title>
    <style type="text/css">
        h1{
            text-align: center;
        }
        h4{
            text-align: center;color: red;
        }
        body{
            background-color: antiquewhite;
        }
        div{
            text-align: center;
        }
    </style>
</head>
<body>
    <h1>添加购物车失败</h1>
    <hr>
    <h4>请重新添加</h4>
    <div>
        <a href="javascript: window.history.go(-1)">返回上一级</a>
    </div>
</body>
</html>

doInfo.jsp

<%--
  Created by IntelliJ IDEA.
  User: shuijianshiqing
  Date: 2020/5/24
  Time: 10:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ page import="com.sjsq.po.Book" %>
<%@ page import="com.sjsq.service.BookService" %>
<%@ page import="com.sjsq.service.impl.BookServiceImpl" %>
    <%
        // 获取绝对路径路径 ,开发项目一定要使用绝对路径,不然肯定出错
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":"
                + request.getServerPort() + path + "/";
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath %>" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>书籍信息</title>
</head>
<body>
    <%
        Book book = new Book();
        String sid = request.getParameter("bookid");
        Integer id = Integer.parseInt(sid);
        BookService service = new BookServiceImpl();
        book.setBookid(id);
        Book bookCur = service.getBook(book);
        // 控制台打印出类的信息(日志的前身)
        System.out.print("doInfo.jsp的信息-->");
        System.out.println(bookCur);
        session.setAttribute("book", bookCur);
        response.sendRedirect("detail.jsp");
    %>
</body>
</html>

doregister.jsp

<%--
  Created by IntelliJ IDEA.
  User: shuijianshiqing
  Date: 2020/5/21
  Time: 23:45
  To change this template use File | Settings | File Templates.
--%>
<%@page import="com.sjsq.dao.impl.UserDaoImpl"%>
<%@page import="com.sjsq.dao.UserDao"%>
<%@page import="com.sjsq.po.User"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" 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>处理注册</title>
</head>
<body>
    <%
        // 设置获取注册时的编码为UTF-8
        request.setCharacterEncoding("UTF-8");
        User user=new User();
        //获取register.jsp页面提交的账号和密码
        String name=request.getParameter("name");
        String password=request.getParameter("password");
        String email=request.getParameter("email");
        String phone=request.getParameter("phone");
        //获取register.jsp页面提交的账号和密码设置到实体类User中
        user.setName(name);
        user.setPassword(password);
        user.setEmail(email);
        user.setPhone(phone);
        //引入数据交互层
        UserDao dao=new UserDaoImpl();
        boolean flag=dao.register(user);
        if(flag){
            response.sendRedirect("login.jsp");
        }else{
            response.sendRedirect("register.jsp");
        }
    %>
</body>
</html>

dosearchPassword.jsp

<%--
  Created by IntelliJ IDEA.
  User: shuijianshiqing
  Date: 2020/5/22
  Time: 23:23
  To change this template use File | Settings | File Templates.
--%>
<%@page import="java.util.List"%>
<%@page import="com.sjsq.service.impl.UserServiceImpl"%>
<%@page import="com.sjsq.po.User"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
    <%
        // 获取绝对路径路径 ,开发项目一定要使用绝对路径,不然肯定出错
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":"
                + request.getServerPort() + path + "/";
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath %>" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>处理找回密码</title>
</head>
<body>
    <%
        User user=new User();
        //获取searchPassword.jsp页面提交的账号和密码
        String name=request.getParameter("name");
        user.setName(name);
        UserServiceImpl service=new UserServiceImpl();
        List<User> list=service.selectUser(user);
        request.setAttribute("list", list);
        for(User u:list){
            request.setAttribute("user", u);
            out.print(u);
        }
        if(user!=null){
            //response.sendRedirect("search.jsp");//不传输数据的转发
            request.getRequestDispatcher("search.jsp").forward(request, response);
        }
    %>
</body>
</html>

fail.jsp

<%--
  Created by IntelliJ IDEA.
  User: shuijianshiqing
  Date: 2020/5/26
  Time: 23:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>登录失败</title>
    <style type="text/css">
        h1{
            text-align: center;
        }
        h4{
            text-align: center;color: red;
        }
        body{
            background-color: antiquewhite;
        }
        div{
            text-align: center;
        }
    </style>
</head>
<body>
    <h1>现存图书列表</h1>
    <hr>
    <h4>登录失败</h4>
    <div>
        <a href="login.jsp">返回登录</a>
    </div>
</body>
</html>

info.jsp

<%--
  Created by IntelliJ IDEA.
  User: shuijianshiqing
  Date: 2020/5/26
  Time: 22:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ page import="com.sjsq.po.User"%>
<%@ page import="com.sjsq.dao.UserDao"%>
<%@ page import="com.sjsq.dao.impl.UserDaoImpl"%>
<%@ page import="com.sjsq.service.UserService" %>
<%@ page import="com.sjsq.service.impl.UserServiceImpl" %>
<%@ page import="java.util.List" %>
<%
        // 获取绝对路径路径 ,开发项目一定要使用绝对路径,不然肯定出错
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":"
                + request.getServerPort() + path + "/";
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath %>" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>用户登录</title>
    <style type="text/css">
        h1{
            text-align: center;
        }
        h4{
            text-align: center;color: red;
        }
        body{
            background-color: antiquewhite;
        }
    </style>
</head>
<body>
    <h1>现存图书列表</h1>
    <hr>
    <h4>---装饰中---</h4>
    <%
        // 设置接收的编码为UTF-8
        request.setCharacterEncoding("utf-8");
        User user = new User();
        UserDao dao = new UserDaoImpl();
        String name = request.getParameter("name");
        String password=request.getParameter("password");
        user.setName(name);
        user.setPassword(password);
        User us=dao.login(user);
        // 把数据库里面的User获取出来
        UserService service = new UserServiceImpl();
        List<User> list = service.selectUser(user);
        for(int i=0;i<list.size();i++){
            user = list.get(i);
        }
        System.out.println("显示用户信息:");
        System.out.println(user);
        session.setAttribute("user",user);
        if(us != null){
            response.sendRedirect("book.jsp");
        }else{
            response.sendRedirect("fail.jsp");
        }
    %>
</body>
</html>

login.jsp

<%--
  Created by IntelliJ IDEA.
  User: shuijianshiqing
  Date: 2020/5/19
  Time: 22:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
    <%
        // 获取绝对路径路径 ,开发项目一定要使用绝对路径,不然肯定出错
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":"
                + request.getServerPort() + path + "/";
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath %>" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>用户登录</title>
    <style type="text/css">
        h1{
            text-align: center;
        }
        h4{
            text-align: center;color: red;
        }
        body{
            background-color: antiquewhite;
        }
        a{
            text-decoration: none;font-size: 20px;color: black;
        }
        a:hover{
            text-decoration: underline;font-size: 24px;color: red;
        }
    </style>
</head>
<body>
    <form action="info.jsp" method="post">
        <h1>用户登录</h1>
        <h4>---正在美化中---</h4>
        <hr/>
        <table align="center">
            <tr>
                <td>账号:</td>
                <td><input type="text" name="name" id="name" placeholder="请输入您的账号" autofocus="autofocus"></td>
            </tr>
            <tr>
                <td>密码:</td>
                <td><input type="password" name="password" id="password" placeholder="请输入您的密码"></td>
                <td><a href="searchPassword.jsp">找回密码</a></td>
            </tr>
            <tr>
                <td colspan="1">
                </td>
                <td>
                    <input type="submit" value="登录"/>
                    <input type="reset" value="重置"/>
                    <a href="register.jsp" target="_blank">注册</a>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

logout.jsp

<%--
  Created by IntelliJ IDEA.
  User: shuijianshiqing
  Date: 2020/5/25
  Time: 21:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>退出登录</title>
</head>
<body>
    <%
        session.invalidate();
        response.sendRedirect("login.jsp");
    %>
</body>
</html>

register.jsp

<%--
  Created by IntelliJ IDEA.
  User: shuijianshiqing
  Date: 2020/5/21
  Time: 23:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>用户注册</title>
    <style type="text/css">
        h1{
            text-align: center;
        }
        h4{
            text-align: center;color: red;
        }
        body{
            background-color: antiquewhite;
        }
        div{
            text-align: center;
        }
    </style>
</head>
<body>
    <h1>用户注册</h1>
    <h4>---装饰中---</h4>
    <hr/>
    <form action="doregister.jsp" method="post" name="registerForm">
        <div>
            <tr>
                <label>您的账号:</label>
                <input type="text" name="name" id="name" placeholder="请输入用户名" autofocus="autofocus">
            </tr>
        </div>
        <div>
            <tr>
                <label>您的密码:</label></td>
                <input type="password" name="password" id="password" placeholder="请输入密码">
            </tr>
        </div>
        <div>
            <tr>
            </tr>
            <label>确认密码:</label>
            <input type="password" name="relpassword" id="relpassword" placeholder="请确认密码">
        </div>
        <div>
            <tr>
                <label>电话号码:</label>
                <input type="text" name="phone" id="phone" placeholder="请输入电话号码">
            </tr>
        </div>
        <div>
            <tr>
                <label>电子邮件:</label>
                <input type="text" name="email" id="email" placeholder="请输入电子邮件">
            </tr>
        </div>
        <div>
            <tr>
                <button type="submit" onclick="return checkForm()">注册</button>
                <button type="reset">重置</button>
                <a href="login.jsp" target="_blank">登录</a>
            </tr>
        </div>
    </form>
    <script type="text/javascript">
        function checkForm() {
            var name = registerForm.name.value;
            var pwd = registerForm.password.value;
            var repwd = registerForm.relpassword.value;
            //alert(name + pwd + repwd);
            if (name == "" || name == null) {
                alert("请输入用户名");
                registerForm.name.focus();
                return false;
            } else if (pwd == "" || pwd == null) {
                alert("请输入密码");
                registerForm.password.focus();
                return false;
            } else if (repwd == "" || repwd == null) {
                alert("请输入确认密码");
                registerForm.relpassword.focus();
                return false;
            } else if (pwd != repwd) {
                alert("两次密码输入不一致,请重新输入!");
                registerForm.relpassword.focus();
                return false;
            }
            alert('注册成功!');
            return true;
        }
    </script>
</body>
</html>

search.jsp

<%--
  Created by IntelliJ IDEA.
  User: shuijianshiqing
  Date: 2020/5/22
  Time: 23:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%
    // 获取绝对路径路径 ,开发项目一定要使用绝对路径,不然肯定出错
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":"
            + request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath %>" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>弹出信息</title>
    <script type="text/javascript">
        alert("您的密码是:${user.password}");
    </script>
    <style type="text/css">
        h1{
            text-align: center;
        }
        div{
            text-align: center;
        }
    </style>
</head>
<body>
    <h1>您的密码是:${user.password}</h1>
    <div>
        <a href="javascript: window.history.go(-1)">返回上一级</a>
    </div>
</body>
</html>

searchPassword.jsp

<%--
  Created by IntelliJ IDEA.
  User: shuijianshiqing
  Date: 2020/5/22
  Time: 23:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%
    // 获取绝对路径路径 ,开发项目一定要使用绝对路径,不然肯定出错
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":"
            + request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath %>" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>找回密码</title>
    <style type="text/css">
        h1{
            text-align: center;
        }
        div{
            text-align: center;
        }
        body{
            background-color:antiquewhite;
        }
    </style>
</head>
<body>
    <h1>找回密码</h1>
    <div>
        <a href="javascript: window.history.go(-1)">返回上一级</a>
    </div>
    <form action="dosearchPassword.jsp" method="post">
        <table align="center">
            <tr>
                <td>请输入账号:</td>
                <td><input type="text" name="name"/></td>
            </tr>
            <tr>
                <td colspan="1"></td>
                <td>
                    <input type="submit" value="提交">
                    <input type="reset" value="重置">
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
2月前
|
Java 应用服务中间件 Shell
Nginx+Keepalived+Tomcat 实现Web高可用集群
Nginx+Keepalived+Tomcat 实现Web高可用集群
76 0
|
21天前
|
存储 关系型数据库 MySQL
【Java面试题汇总】MySQL数据库篇(2023版)
聚簇索引和非聚簇索引、索引的底层数据结构、B树和B+树、MySQL为什么不用红黑树而用B+树、数据库引擎有哪些、InnoDB的MVCC、乐观锁和悲观锁、ACID、事务隔离级别、MySQL主从同步、MySQL调优
【Java面试题汇总】MySQL数据库篇(2023版)
|
1月前
|
自然语言处理 算法 Java
Java如何判断两句话的相似度类型MySQL的match
【9月更文挑战第1天】Java如何判断两句话的相似度类型MySQL的match
20 2
|
2月前
|
存储 缓存 前端开发
Servlet与JSP在Java Web应用中的性能调优策略
Servlet与JSP在Java Web应用中的性能调优策略
26 1
|
2月前
|
安全 Java 关系型数据库
Java连接Mysql SSL初始化失败
Java连接Mysql SSL初始化失败
|
2月前
|
关系型数据库 Java MySQL
Linux安装JDK1.8 & tomcat & MariaDB(MySQL删减版)
本教程提供了在Linux环境下安装JDK1.8、Tomcat和MariaDB的详细步骤。这三个组件的组合为Java Web开发和部署提供了一个强大的基础。通过遵循这些简单的指导步骤,您可以轻松建立起一个稳定、高效的开发和部署环境。希望这个指导对您的开发工作有所帮助。
109 8
|
2月前
|
网络协议 Java 应用服务中间件
Tomcat源码分析 (一)----- 手撕Java Web服务器需要准备哪些工作
本文探讨了后端开发中Web服务器的重要性,特别是Tomcat框架的地位与作用。通过解析Tomcat的内部机制,文章引导读者理解其复杂性,并提出了一种实践方式——手工构建简易Web服务器,以此加深对Web服务器运作原理的认识。文章还详细介绍了HTTP协议的工作流程,包括请求与响应的具体格式,并通过Socket编程在Java中的应用实例,展示了客户端与服务器间的数据交换过程。最后,通过一个简单的Java Web服务器实现案例,说明了如何处理HTTP请求及响应,强调虽然构建基本的Web服务器相对直接,但诸如Tomcat这样的成熟框架提供了更为丰富和必要的功能。
|
2月前
|
存储 SQL 关系型数据库
深入MySQL锁机制:原理、死锁解决及Java防范技巧
深入MySQL锁机制:原理、死锁解决及Java防范技巧
|
2月前
|
存储 Java 关系型数据库
基于Servlet和JSP的Java Web应用开发指南
基于Servlet和JSP的Java Web应用开发指南
18 0
下一篇
无影云桌面