spring boot Thymeleaf模板引擎 最简单输出例子

一 、spring boot  Thymeleaf模板引擎  最简单输出例子

 

控制器代码如下:

@GetMapping(value = "/test")
public String test(Model model){

    List<Boy> boy  = new ArrayList<Boy>();
    boy.add(new Boy("xx",11));
    boy.add(new Boy("yy",22));
    boy.add(new Boy("zz",33));
    model.addAttribute("boy", boy);
    return  "helloHtml";
}

模板代码如下:
<ul>
    <li th:each="a:${boy}">
        <span th:text="${a.id}"></span>
        <span th:text="${a.cupSize}"></span>

    </li>
</ul>
 

 

 

posted @ 2018-01-20 21:14  多啦C梦  阅读(1239)  评论(0编辑  收藏  举报