我试图在thymleaf中迭代functionList
。这就是我所做的。
控制器:
@RequestMapping(value = "/list",method = RequestMethod.GET)
public ModelAndView getFunctionList(HttpServletRequest request){
ModelAndView mav = new ModelAndView("adminConfigurationFunction");
List<Function> functionList = functionService.getList();
mav.addObject("list", functionList);
return mav;
}
并在html中:
<table class="table table-striped table-condensed margin-top-20">
<tr>
<th>Name</th>
<th>Description</th>
</tr>
<tr th:each="func : ${functionList}" >
<td th:text="${func.name}"></td>
<td th:text="${func.description}"></td>
</tr>
</table>
我是新来的。我做错了什么?或者我应该使用th:for
?
答案 0 :(得分:1)
我找到了答案。
<tr th:each="func : ${list}" >
<td th:text="${func.name}"></td>
<td th:text="${func.description}"></td>
</tr>
更改了th:each="func : ${functionList}"
:每个=&#34; func:$ {list}&#34;`