1.controller层的方法接收到请求后将返回borrowingBooks.html页面,并将一个List对象res的值传递到borrowingBooks.html页面。
@Controller
public class UserController {
@Resource
private IUserService userService;
@RequestMapping("/userBorrowingBooksPage")
public String userBorrowingBooksPage(Model model,HttpServletRequest request){
List<BorrowingBooksVo> res=userService.findAllBorrowingBooks(request);
model.addAttribute("borrowingBooksList",res);
return "user/borrowingBooks";
}
}
2.borrowingBooks.html页面接收值,并显示。
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>借书页面</title>
</head>
<body>
<b>借书页面</b><br>
<tr th:each="borrowingBooks : ${borrowingBooksList}">
<td><a href="#" th:text="${borrowingBooks.getBook().getBookName()}">Title ...</a></td>
<td th:text="${borrowingBooks.getDate()}">1</td><br>
</tr>
</body>
</html>