zoukankan      html  css  js  c++  java
  • 数据传递,网页模板thymeleaf

    springboot

    网页模板thymeleaf

    POM配置:

    <dependency>
        <groupId>org.thymeleaf</groupId>
        <artifactId>thymeleaf-spring5</artifactId>
    </dependency>
    <dependency>
        <groupId>org.thymeleaf.extras</groupId>
        <artifactId>thymeleaf-extras-java8time</artifactId>
    </dependency>

    模板页配置:

    <html lang="en" xmlns:th="http://www.thymeleaf.org">
    

     

    转意用utext(不是文本)

     后台:

        public String test(Model model) {
            model.addAttribute("msg", "<h1>html.chen</h1>");
            return "/test";
        }

     

    <div th:text="${msg}"></div>
    <div th:utext="${msg}"></div>

    获取数组:

    <h3 th:each="user:${users}" th:text="${user}"></h3>
    model.addAttribute("users", Arrays.asList("chen","li"));

     在标签内插入数据

    <h3 th:each="user:${users}">[[${user}]]</h3>   
  • 相关阅读:
    成员变量和局部变量
    成员变量和局部变量
    对象和类
    数组
    Scanner--控制台输入
    Java运算符
    Java数据类型
    TextView控件
    Android控件
    注释
  • 原文地址:https://www.cnblogs.com/bingxing/p/13652102.html
Copyright © 2011-2022 走看看