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>
 
 
 
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号