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

简介: 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>
相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
相关文章
|
SQL Java 关系型数据库
Java连接MySQL数据库环境设置指南
请注意,在实际部署时应该避免将敏感信息(如用户名和密码)硬编码在源码文件里面;应该使用配置文件或者环境变量等更为安全可靠地方式管理这些信息。此外,在处理大量数据时考虑使用PreparedStatement而不是Statement可以提高性能并防止SQL注入攻击;同时也要注意正确处理异常情况,并且确保所有打开过得资源都被正确关闭释放掉以防止内存泄漏等问题发生。
513 13
|
Java 应用服务中间件 Maven
在IntelliJ IDEA中如何配置使用Maven以创建Tomcat环境
所以,别担心这些工具看起来有些吓人,实际上这些都是为了帮助你更好的完成工作的工具,就像超市里的各种烹饪工具一样,尽管它们看起来可能很复杂,但只要你学会用,它们会为你烹饪出一道道美妙的食物。这就是学习新技能的乐趣,让我们一起享受这个过程,攀登知识的高峰!
903 27
|
Java 应用服务中间件 Apache
在IntelliJ IDEA中使用Maven配置Tomcat环境
此配置方法具有较高的实用性,简单易懂。遵循以上步骤,您将能顺利在IntelliJ IDEA中使用Maven配置Tomcat环境,从而进行Web项目的开发和调试。
1967 18
|
开发框架 Java 关系型数据库
在Linux系统中安装JDK、Tomcat、MySQL以及部署J2EE后端接口
校验时,浏览器输入:http://[your_server_IP]:8080/myapp。如果你看到你的应用的欢迎页面,恭喜你,一切都已就绪。
909 17
|
Java 关系型数据库 MySQL
在Linux操作系统上设置JDK、Tomcat、MySQL以及J2EE后端接口的部署步骤
让我们总结一下,给你的Linux操作系统装备上最强的军队,需要先后装备好JDK的弓箭,布置好Tomcat的阵地,再把MySQL的物资原料准备好,最后部署好J2EE攻城车,那就准备好进军吧,你的Linux军团,无人可挡!
669 18
|
关系型数据库 MySQL Java
安装和配置JDK、Tomcat、MySQL环境,以及如何在Linux下更改后端端口。
遵循这些步骤,你可以顺利完成JDK、Tomcat、MySQL环境的安装和配置,并在Linux下更改后端端口。祝你顺利!
799 11
|
人工智能 Java 关系型数据库
Java的时间处理与Mysql的时间查询
本文总结了Java中时间与日历的常用操作,包括时间的转换、格式化、日期加减及比较,并介绍了MySQL中按天、周、月、季度和年进行时间范围查询的方法,适用于日常开发中的时间处理需求。
270 0
|
12月前
|
缓存 关系型数据库 BI
使用MYSQL Report分析数据库性能(下)
使用MYSQL Report分析数据库性能
670 158
|
关系型数据库 MySQL 数据库
自建数据库如何迁移至RDS MySQL实例
数据库迁移是一项复杂且耗时的工程,需考虑数据安全、完整性及业务中断影响。使用阿里云数据传输服务DTS,可快速、平滑完成迁移任务,将应用停机时间降至分钟级。您还可通过全量备份自建数据库并恢复至RDS MySQL实例,实现间接迁移上云。
|
12月前
|
关系型数据库 MySQL 数据库
阿里云数据库RDS费用价格:MySQL、SQL Server、PostgreSQL和MariaDB引擎收费标准
阿里云RDS数据库支持MySQL、SQL Server、PostgreSQL、MariaDB,多种引擎优惠上线!MySQL倚天版88元/年,SQL Server 2核4G仅299元/年,PostgreSQL 227元/年起。高可用、可弹性伸缩,安全稳定。详情见官网活动页。
1774 152

推荐镜像

更多