有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Thymeleaf中大表的java输出

Spring启动应用程序。 我想将一个表中的数据从Book类输出到html。 控制器:

@GetMapping("/books")
public String showBooks(HttpServletRequest request, Model model) {
  allBooks = bookService.getAll();
  model.addAttribute("allBooks", allBooks);
  return "books";
}

我用百里香。 以下是一段html代码:

<table border="1" style="width:250px"> <tr> <th>No</th> <th>Name</th> </tr> <tr th:each="allBooks, state : ${allBooks}"> <td th:utext="${state.count}">No</td> <td th:text="${allBooks.name}">A Book'</td> </tr> </table>

图书班有100多个条目。 如何正确显示它们,使它们每页显示10个条目? Thymeleaf能做到这一点吗?还是我需要使用javaScript


共 (0) 个答案