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

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: 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
相关文章
|
24天前
|
关系型数据库 MySQL Java
【IDEA】java后台操作mysql数据库驱动常见错误解决方案
【IDEA】java后台操作mysql数据库驱动常见错误解决方案
49 0
|
18天前
|
Java 关系型数据库 MySQL
自动化测试项目实战笔记(一):JDK、Tomcat、MySQL、Jpress环境安装和搭建
这篇文章是关于自动化测试项目实战笔记,涵盖了JDK、Tomcat、MySQL、Jpress环境的安装和搭建过程,以及测试用例和常见问题总结。
34 1
自动化测试项目实战笔记(一):JDK、Tomcat、MySQL、Jpress环境安装和搭建
|
19天前
|
存储 缓存 Java
java基础:IO流 理论与代码示例(详解、idea设置统一utf-8编码问题)
这篇文章详细介绍了Java中的IO流,包括字符与字节的概念、编码格式、File类的使用、IO流的分类和原理,以及通过代码示例展示了各种流的应用,如节点流、处理流、缓存流、转换流、对象流和随机访问文件流。同时,还探讨了IDEA中设置项目编码格式的方法,以及如何处理序列化和反序列化问题。
50 1
java基础:IO流 理论与代码示例(详解、idea设置统一utf-8编码问题)
|
6天前
|
搜索推荐 Java 数据库连接
Java|在 IDEA 里自动生成 MyBatis 模板代码
基于 MyBatis 开发的项目,新增数据库表以后,总是需要编写对应的 Entity、Mapper 和 Service 等等 Class 的代码,这些都是重复的工作,我们可以想一些办法来自动生成这些代码。
16 6
|
25天前
|
NoSQL 关系型数据库 MySQL
Tomcat、MySQL、Redis最大支持说明
综上所述,Tomcat、MySQL、Redis的并发处理能力均非固定值,而是通过合理的配置与优化策略,结合系统硬件资源,共同决定了它们在实际应用中的表现。开发者应根据应用的具体需求和资源条件,对这些组件进行细致的调优,以达到最佳性能表现。
29 0
|
3月前
|
前端开发 Java Maven
【前端学java】全网最详细的maven安装与IDEA集成教程!
【8月更文挑战第12天】全网最详细的maven安装与IDEA集成教程!
85 2
【前端学java】全网最详细的maven安装与IDEA集成教程!
|
3月前
|
Java
`<jsp:getProperty>`动作和`<jsp:setProperty>`动作的使用在一个静态页面填写图书的基本信息,页面信息提交给其他页面,并且在其页面显示。要去将表单元素的值赋值给Java
该博客文章讲解了JSP中`<jsp:getProperty>`和`<jsp:setProperty>`动作的使用方法,包括它们的语法格式和如何在页面中使用这些动作来获取和设置JavaBean对象的属性值,并通过图书信息的填写和展示示例进行了演示。
`<jsp:getProperty>`动作和`<jsp:setProperty>`动作的使用在一个静态页面填写图书的基本信息,页面信息提交给其他页面,并且在其页面显示。要去将表单元素的值赋值给Java
|
3月前
|
Java PHP 数据安全/隐私保护
Java——IDEA如何运行单个文件
Java——IDEA如何运行单个文件
55 1
Java——IDEA如何运行单个文件
|
3月前
|
存储 缓存 前端开发
Servlet与JSP在Java Web应用中的性能调优策略
Servlet与JSP在Java Web应用中的性能调优策略
30 1
|
3月前
|
关系型数据库 MySQL Linux
【Azure 应用服务】在创建Web App Service的时候,选Linux系统后无法使用Mysql in App
【Azure 应用服务】在创建Web App Service的时候,选Linux系统后无法使用Mysql in App
【Azure 应用服务】在创建Web App Service的时候,选Linux系统后无法使用Mysql in App