步骤:
pom文件:导包,写入静态资源导出配置,连接数据库
建包:controller dao/mapper pojo service
配置文件:mybatis-config.xml applicationContext.xml(Spring的配置文件) database.properties
1. mybatis-config.xml
2. applicationContext.xml(Spring的配置文件)
3. database.properties
// 跳转到修改页面
@RequestMapping("/toUpdate")
public String toUpdatePaper(int id, Model model){Books books = bookService.getBooksByID(id);model.addAttribute("QBooks", books);return "updateBook";
}
<%--Created by IntelliJ IDEA.User: wanglDate: 2023/2/17Time: 19:33To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>修改书籍</title><%-- BootStrap美化界面--%><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"></head>
<body>
<%----%>
<div class="container"> <%--使用bootStrap样式--%><div class="row clearfix"> <%--清除浮动--%><div class="clo-md-12 column"> <%--把中等屏幕等分为12份--%><div class="page-header"><h1><small>修改书籍</small></h1></div></div></div><form action="${pageContext.request.contextPath}/book/toUpdate" method="post"><div class="form-group"><label>书籍名称:</label><input type="text" name="bookName" class="form-control" value="${QBooks.bookName}" required> <%--name必须与类定义中的变量名相同,required:前端必须添加了值才能提交--%></div><div class="form-group"><label>书籍数量:</label><input type="text" name="bookCounts" class="form-control" value="${QBooks.bookCounts}" required></div><div class="form-group"><label>书籍描述:</label><input type="text" name="detail" class="form-control" value="${QBooks.detail}" required></div><div class="form-group"><input type="submit" class="form-control" value="修改"></div></form>
</div>
</body>
</html>
${pageContext.request.contextPath}/book/toUpdate?id=${book.bookID}