Skip to content

Commit feaf11f

Browse files
committed
Add Books function
1 parent f67ce64 commit feaf11f

3 files changed

Lines changed: 47 additions & 2 deletions

File tree

‎ssmbuild/src/main/java/top/clearlight/controller/BookController.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,12 @@ public String toAddPage() {
3939
return "addBook";
4040
}
4141

42+
@RequestMapping("/addBook")
43+
public String addBook(Books books) {
44+
System.out.println(books);
45+
bookService.addBook(books);
46+
// 重定向到@RequestMapping("allBook")请求
47+
return "redirect:/book/allBook";
48+
}
49+
4250
}

‎ssmbuild/web/WEB-INF/jsp/addBook.jsp‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,38 @@
99
<html>
1010
<head>
1111
<title>添加书籍</title>
12+
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
1213
</head>
1314
<body>
14-
add Book :)
15+
16+
<div class="container">
17+
<div class="row clearfix">
18+
<div class="col-md-12 column">
19+
<div class="page-header">
20+
<h1>
21+
<small>新增书籍</small>
22+
</h1>
23+
</div>
24+
</div>
25+
</div>
26+
27+
<form action="${pageContext.request.contextPath}/book/addBook" method="post">
28+
<div class="form-group">
29+
<label for="bName">书籍名称:</label>
30+
<input type="text" class="form-control" name="bookName" id="bName" required/>
31+
</div>
32+
<div class="form-group">
33+
<label for="bCounts">书籍数量:</label>
34+
<input type="text" class="form-control" name="bookCounts" id="bCounts" required/>
35+
</div>
36+
<div class="form-group">
37+
<label for="bDetail">书籍描述:</label>
38+
<input type="text" class="form-control" name="detail" id="bDetail" required/>
39+
</div>
40+
<div class="form-group">
41+
<input type="submit" class="form-control" value="添加"/>
42+
</div>
43+
</form>
44+
</div>
1545
</body>
1646
</html>

‎ssmbuild/web/WEB-INF/jsp/allBook.jsp‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<div class="row">
2828
<div class="col-md-4 column">
2929
<%--toAddBook--%>
30-
<a href="${pageContext.request.contextPath}/book/toAddPage">新增书籍</a>
30+
<a href="${pageContext.request.contextPath}/book/toAddPage" class="btn btn-primary">新增书籍</a>
3131
</div>
3232
</div>
3333
</div>
@@ -41,6 +41,7 @@
4141
<th>书籍名称</th>
4242
<th>书籍数量</th>
4343
<th>书籍详情</th>
44+
<th>操作</th>
4445
</tr>
4546
</thead>
4647

@@ -53,11 +54,17 @@
5354
<td>${book.bookName}</td>
5455
<td>${book.bookCounts}</td>
5556
<td>${book.detail}</td>
57+
<td>
58+
<a href="#" class="btn btn-info">修改</a>
59+
&nbsp; | &nbsp;
60+
<a href="#" class="btn btn-info">删除</a>
61+
</td>
5662
</tr>
5763
</c:forEach>
5864
</tbody>
5965
</table>
6066
</div>
6167
</div>
68+
</div>
6269
</body>
6370
</html>

0 commit comments

Comments
 (0)