zoukankan      html  css  js  c++  java
  • jdbcTemplate 和 Thymeleaf模板引擎 查询 到模板赋值例子

    二、  jdbcTemplate 和 Thymeleaf模板引擎  最简单输出例子

    控制器代码

    @GetMapping(value = "/test2")
        public String test2(Model model){
    
            sql = "SELECT * FROM boy ";
            List queryList = jdbcTemplate.queryForList(sql);
    
            model.addAttribute("boy", queryList);
            return  "aaa";
    
        }

    html模板里的代码

    <ul>
        <li th:each="a:${boy}">
            <span th:text="${a.id}"></span>
            <span th:text="${a.age}"></span>
            <span th:text="${a.cup_size}"></span>
    
        </li>
    </ul>

    注意,模板里的

    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
          xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
    不要漏了下面这句
    xmlns:th="http://www.thymeleaf.org"
  • 相关阅读:
    8.26 树状数组
    8.27 神异之旅
    8.26 雇佣
    8.28 Jack与Rose
    8.28 ISN
    保存和加载网络
    快速搭建网络
    分类网络
    torch中的回归
    pytorch中的Variable
  • 原文地址:https://www.cnblogs.com/kaka666/p/8322407.html
Copyright © 2011-2022 走看看