【问题标题】:Iterating in thymleaf百里香叶中的迭代
【发布时间】: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 个条目,但在我的页面上没有显示任何内容。

标签: spring thymeleaf


【解决方案1】:

我找到了答案。

<tr th:each="func : ${list}" >
<td th:text="${func.name}"></td>
<td th:text="${func.description}"></td>
</tr>

更改th:each="func : ${functionList}" th:each="func : ${list}"`

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-14
    • 2015-11-29
    • 1970-01-01
    • 2017-04-05
    • 2015-12-09
    • 2018-07-08
    相关资源
    最近更新 更多