我需要得到数据从html到控制器与按下按钮也Html数据作为列表。
<thead>
<tr>
<th>Company Name</th>
<th>Book Name</th>
<th>Author</th>
<th>Price</th>
<th>Order</th>
</tr>
</thead>
<tbody>
<tr th:each="Books: ${Books }">
<td th:text="${Books.CompanyName}" />
<td th:text="${Books.BookName}" />
<td th:text="${Books.AuthorName}" />
<td th:text="${Books.Price}" />
<td th:button class="Order-Button" type="button" >Order</button> </td>
这也是我的控制器
@Autowired
private BookRep bookRep;
@RequestMapping(value = "/BookOrder")
ModelAndView submitBookOrder(){
ModelAndView mav = new ModelAndView("BookOrder");
mav.addObject("Books", bookRep.findAll());
return mav;
}
我希望当用户按下接受订单按钮时,它将在控制器中获得行数据
1条答案
按热度按时间l7mqbcuq1#
我为你写了演示代码。我想它对你会有用。你可以通过看代码来了解你想要什么
<-td>图书<-a th:href="@{/Books/{id}(id = ${book.id})}"><-button type="submit" class="btn btn-info col-2" style="min-width: fit-content">列表〈-/button〉