index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE HTML>
<title>首页
<style type="text/css">
a {
text-decoration:none;
color:black;
font-size:18px;
}
h3 {
width:180px;
height:38px;
margin:100px auto;
text-align:center;
line-height:38px;
background:deepskyblue;
border-radius:4px;
}
<a href="${pageContext.request.contextPath}/book/allBook">点击进入列表页
</html>
addBook.xml
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<title>新增书籍
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 引入Bootstrap -->
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<div class="page-header">
<small>新增书籍
<form action="${pageContext.request.contextPath}/book/addBook" method="post">
书籍名称:<input type="text" name="bookName">
书籍数量:<input type="text" name="bookCounts">
书籍详情:<input type="text" name="detail">
<input type="submit" value="添加">
</div>
allBook.xml
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<title>书籍列表
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 引入Bootstrap -->
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<div class="page-header">
<small>书籍列表 ——显示所有书籍
<div class="row">
<div class="col-md-4 column">
<a class="btn btn-primary" href="${pageContext.request.contextPath}/book/toAddBook">新增
<div class="row clearfix">
<div class="col-md-12 column">
<table class="table table-hover table-striped">
<th>书籍编号
<th>书籍名字
<th>书籍数量
<th>书籍详情
<th>操作
<c:forEach var="book" items="${requestScope.get('list')}">
<td>${book.getBookID()}
<td>${book.getBookName()}
<td>${book.getBookCounts()}
<td>${book.getDetail()}
<a href="${pageContext.request.contextPath}/book/toUpdateBook?id=${book.getBookID()}">更改</a> |
<a href="${pageContext.request.contextPath}/book/del/${book.getBookID()}">删除
</c:forEach>
</div>
updateBook
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<title>修改信息
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 引入Bootstrap -->
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<div class="page-header">
<small>修改信息
<form action="${pageContext.request.contextPath}/book/updateBook" method="post">
<input type="hidden" name="bookID" value="${book.getBookID()}"/>
书籍名称:<input type="text" name="bookName" value="${book.getBookName()}"/>
书籍数量:<input type="text" name="bookCounts" value="${book.getBookCounts()}"/>
书籍详情:<input type="text" name="detail" value="${book.getDetail() }"/>
<input type="submit" value="提交"/>
</div>