【后端】Thymeleaf模板引擎学习笔记


视频地址

1. java体系模板引擎介绍

  • FreeMarker
  • Thymeleaf
  • Velocity

在这里插入图片描述

2. 使用

2.1 初步使用

  • 引入依赖
 <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf</artifactId>
            <version>3.0.9.RELEASE</version>
</dependency>
  • 初步使用
@Test
    public void fun01() {
        //创建模板引擎
        TemplateEngine templateEngine = new TemplateEngine();
        //准备模板
        String input = "<input type='text' th:value='hellothymeleaf'/>";
        //准备数据,使用context
        Context context = new Context();
        //调用模板引擎,处理模板和数据
        String out = templateEngine.process(input, context);
        System.out.println("结果数据:" + out);
    }

相关推荐

  1. 【Spring Boot】thymeleaf模板引擎

    2024-04-21 09:10:01       32 阅读
  2. 学习笔记

    2024-04-21 09:10:01       49 阅读
  3. 】OFD学习笔记

    2024-04-21 09:10:01       40 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-21 09:10:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-21 09:10:01       101 阅读
  3. 在Django里面运行非项目文件

    2024-04-21 09:10:01       82 阅读
  4. Python语言-面向对象

    2024-04-21 09:10:01       91 阅读

热门阅读

  1. Mysql 和 PostgreSQL 到底选啥?

    2024-04-21 09:10:01       38 阅读
  2. NLOS中如何提取出首达路径

    2024-04-21 09:10:01       29 阅读
  3. 【python】python基础学习笔记

    2024-04-21 09:10:01       34 阅读
  4. 使用 Cucumber框架进行BDD测试的一些项目

    2024-04-21 09:10:01       28 阅读
  5. 2024年学习计划

    2024-04-21 09:10:01       30 阅读
  6. Stylus 入门使用方法

    2024-04-21 09:10:01       31 阅读
  7. Stylus入门使用方法

    2024-04-21 09:10:01       45 阅读
  8. stylus入门使用方法

    2024-04-21 09:10:01       40 阅读
  9. leetcode748-Shortest Completing Word

    2024-04-21 09:10:01       32 阅读