zoukankan      html  css  js  c++  java
  • thymeleaf 的使用(三)--举例使用

    controller代码:

    1     @RequestMapping("/success")
    2     public String success(Map<String,Object> map){
    3         map.put("hello", "<h1>你好</h1>");
    4         map.put("users", Arrays.asList("张三","李四","王五"));
    5         return "success";
    6     }

    HTML代码:

     1 <!DOCTYPE html>
     2 <html lang="en" xmlns:th="http://www.thymeleaf.org">
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>success</title>
     6 </head>
     7 <body>
     8 <h1>成功!!!</h1>
     9 <div id="i1" class="myDiv" th:id="${hello}" th:class="${hello}" th:text="${hello}">这里显示欢迎信息</div>
    10 <hr/>
    11 <div th:text="${hello}"></div>
    12 <div th:utext="${hello}"></div>
    13 <hr/>
    14 <!-- th:each每次遍历都会生成当前这个标签-->
    15 <h3 th:text="${user}" th:each="user:${users}"></h3>
    16 <h3>
    17     <span th:text="${user}" th:each="user:${users}"></span>
    18 </h3>
    19 </body>
    20 </html>

    浏览器访问:loacalhost:8080/success

  • 相关阅读:
    查看数据库表中的数据
    exec和execsql
    CPI
    百度硬盘可以检索的字节测试
    HDU2095
    Vigenere密码
    斌神无所不能
    HDU p1017
    POJ1316
    head区的代码详解
  • 原文地址:https://www.cnblogs.com/Ryan368/p/13675991.html
Copyright © 2011-2022 走看看