zoukankan      html  css  js  c++  java
  • 小D课堂

    笔记

    4、SpringBoot2.x整合模板引擎thymeleaf实战
        讲解:SpringBoot2.x整合模板引擎thymeleaf实战

        官网地址:https://www.thymeleaf.org/doc/articles/thymeleaf3migration.html
        1、thymeleaf相关maven依赖
                <dependency>
                       <groupId>org.springframework.boot</groupId>
                       <artifactId>spring-boot-starter-thymeleaf</artifactId>
                </dependency>

        2、thymeleaf基础配置

            #开发时关闭缓存,不然没法看到实时页面
            spring.thymeleaf.cache=false
            spring.thymeleaf.mode=HTML5
            #前缀
            spring.thymeleaf.prefix=classpath:/templates/
            #编码
            spring.thymeleaf.encoding=UTF-8
            #类型
            spring.thymeleaf.content-type=text/html
            #名称的后缀
            spring.thymeleaf.suffix=.html

        3、建立文件夹
            1)src/main/resources/templates/tl/
            2)建立一个index.html

        4、简单测试代码编写和访问
            注意:$表达式只能写在th标签内部
            快速入门:https://www.thymeleaf.org/doc/articles/standarddialect5minutes.html

    开始 


    配置文件



    配置的跟路径直接指名了是templates下的tl文件夹作为根路径




    controller


    启动应用





    把templates文件夹加入到springboot的默认加载路径里面去。在application.properties这里spring.resources.static-locations里面配置

    所以需要把templates也加入到配置中。这样templates文件就会作为springboot默认加载会扫描加载的静态资源文件




    取数据,跳转到静态页




    th:text:模板语法替换了测试内容

    直接访问静态页

    快速入门:https://www.thymeleaf.org/doc/articles/standarddialect5minutes.html




     

  • 相关阅读:
    Android总结之json解析(FastJson Gson 对比)
    Android性能优化之UncaughtExceptionHandler定制自己的错误日志系统
    IOS遍历网页获取网页中<img>标签中的图片url
    IOS各种集合遍历效率对比
    cx_oracle访问处理oracle中文乱码问题
    使用tar解压文件提示gzip: stdin: not in gzip format错误
    Mac安装crfpp
    oracle 常用操作
    docker启动centos7后sudo不能使用
    常见Python爬虫工具总结
  • 原文地址:https://www.cnblogs.com/wangjunwei/p/11421765.html
Copyright © 2011-2022 走看看