后端控制层传递过来的List
@RequestMapping("/enter")
public String enter(Model model){
List<Pet> petList = petMapper.queryAllPet();
model.addAttribute("petList",petList);
return "allPet";
}
发现在html中使用thymeleaf
总是拿不到数据,list
点不出来东西
<tr th:each=" list: ${petList}">
<td th:text="${list.petID}"></td>
<td th:text="${list.petName}"></td>
<td th:text="${list.petCounts}"></td>
<td th:text="${list.detail}"></td>
</tr>
百思不得其解,然后终于发现:
<html lang="en" xmlns:th="http://www.thymeleaf.org">
要导入命名空间的约束!!!!!!!!!!!!!!
细节细节细节
重要的事说三遍