【发布时间】:2015-07-07 05:08:27
【问题描述】:
我试图在 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?
【问题讨论】:
-
结果如何? th:每个都很好
-
@MartinFrey 该列表包含 3 个条目,但在我的页面上没有显示任何内容。