一、SpringBoot整合freemarker:

  1.引入freemarker模板依赖:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
<version>1.5.9.RELEASE</version>
</dependency>

  2.配置application.properties:

#freemarker 静态资源配置
#设定ftl文件路径
spring.freemarker.template-loader-path=classpath:/templates
#关闭缓存,还是刷新,上线生产环境需要改为true
spring.freemarker.cache=false
spring.freemarker.charset=utf-
spring.freemarker.check-template-location=true
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=true
spring.freemarker.expose-session-attributes=true
spring.freemarker.request-context-attribute=request
spring.freemarker.suffix=.ftl

  3.在resources目录下建个目录叫templates,在这个目录下新建一个以.ftl结尾的文件,并且将html代码复制进去,在controller层返回这个视图

二、SpringBoot整合thymeleaf

  1.引入thymeleaf模板依赖

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>1.5.9.RELEASE</version>
</dependency>

  2.配置application.properties:

#thymeleaf静态资源配置
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-
spring.thymeleaf.content-type=text/html
#关闭缓存,即时刷新,上线生产环境需要改为true
spring.thymeleaf.cache=true

  3.在resoureces下新建个目录templates在里面编写html文件,具体的thymeleaf标签语法这里就不做介绍了。

SpringBoot整合模板引擎的更多相关文章

  1. springboot配置server相关配置&整合模板引擎Freemarker、thymeleaf&thymeleaf基本用法&thymeleaf 获取项目路径 contextPath 与取session中信息

    1.Springboot配置server相关配置(包括默认tomcat的相关配置) 下面的配置也都是模板,需要的时候在application.properties配置即可 ############## ...

  2. 【SpringBoot】常用Starter介绍和整合模板引擎Freemaker、thymeleaf

    ========7.SpringBoot常用Starter介绍和整合模板引擎Freemaker.thymeleaf ========================= 1.SpringBoot Sta ...

  3. SpringBoot常用Starter介绍和整合模板引擎Freemaker、thymeleaf 4节课

    1.SpringBoot Starter讲解 简介:介绍什么是SpringBoot Starter和主要作用 1.官网地址:https://docs.spring.io/spring-boot/doc ...

  4. SpringBoot入门系列(四)整合模板引擎Thymeleaf

    前面介绍了Spring Boot的优点,然后介绍了如何快速创建Spring Boot 项目.不清楚的朋友可以看看之前的文章:https://www.cnblogs.com/zhangweizhong/ ...

  5. 小D课堂 - 零基础入门SpringBoot2.X到实战_第7节 SpringBoot常用Starter介绍和整合模板引擎Freemaker、thymeleaf_28..SpringBoot Starter讲解

    笔记 1.SpringBoot Starter讲解     简介:介绍什么是SpringBoot Starter和主要作用 1.官网地址:https://docs.spring.io/spring-b ...

  6. Spring Boot整合模板引擎jsp

    jsp也算是一种模板引擎吧.整合jsp前,先说一下运行SpringBoot项目的几种方式 1. 运行SpringBoot项目的几种方式 1.1 使用内嵌Tomcat运行项目 在IDE中右键运行启动类, ...

  7. springboot集成模板引擎freemarker和thymeleaf

    freemarkder和thymeleaf都是java的模板引擎,这里只介绍这两种模板引擎如何在sprongboot中配置: 1. freemarkder 1.1 在pom.xml中添加依赖包 < ...

  8. SpringBoot:模板引擎 thymeleaf、ContentNegotiatingViewResolver、格式化转换器

    目录 模板引擎 thymeleaf ContentNegotiatingViewResolver 格式化转换器 模板引擎 thymeleaf.ContentNegotiatingViewResolve ...

  9. SpringBoot系统列 5 - 接口版本控制、SpringBoot FreeMarker模板引擎

    接着上篇博客的代码继续写 1.接口版本控制 一个系统上线后会不断迭代更新,需求也会不断变化,有可能接口的参数也会发生变化,如果在原有的参数上直接修改,可能会影响线上系统的正常运行,这时我们就需要设置不 ...

随机推荐

  1. @property、@sythesize以及Ivar和@dynamic讲解(下)

    下面仅仅是一些基本知识,可能有些知识用的比较少,不过知道怎么使用或者了解这个知识,还是不错的,毕竟技多不压身嘛!读完这篇文章大约需要5-10分钟左右!!! 一.@property 1.在头文件中: @ ...

  2. “笨方法”学习Python笔记(1)-Windows下的准备

    Python入门书籍 来自于开源中国微信公众号推荐的一篇文章 全民Python时代,豆瓣高级工程师告诉你 Python 怎么学 问:请问你目前最好的入门书是那本?有没有和PHP或者其他语言对比讲Pyt ...

  3. C#面向对象之封装。

    封装是面向对象的基础和重要思想之一,今天具体的了解封装这一特性后发现其实自己已经接触过很多关于封装的内容了. 一.什么是封装. 封装的概念:将具体的实现细节装到一个容器中,封闭或隐藏起来(使用访问修饰 ...

  4. Go vs .NET Core 2.1

    .NET Core 2.1 正式发布之际,微软团队在博客的中提到了 .NET Core 2.1 中的性能提升.这让我想起了去年 Go 语言 Iris MVC 框架作者做的 Go 与 .NET Core ...

  5. Codeforces617E(莫队)

    E. XOR and Favorite Number time limit per test: 4 seconds memory limit per test: 256 megabytes input ...

  6. vue2 兼容ie8

    推荐这个 https://cdn.jsdelivr.net/npm/ractive

  7. angularjs-select2的使用

    1.引入文件 '/select2.css', '/select2-bootstrap.css', '/select2.min.js', ‘/angular-select2.min.js’ 2.页面 3 ...

  8. 照葫芦画瓢系列之Java --- Maven的集成和使用

    一.和Eclipse的集成 1.添加Maven 在windows--> preferences中找到maven选项,如下图: 如果没有上图的Name为apache-maven-3.5.2的项,则 ...

  9. Windchill_IBA属性

    IBA属性:也可以称为软属性,创建IBA属性后并不会改变已有对象的数据库表结构,IBA的属性名和属性值由专门的表存放. StringDefinition表:字符串类型的IBA属性定义 :StringV ...

  10. 什么是CSR以及CSR的作用和生成

    什么是CSR以及CSR的作用和生成 来源:https://www.trustasia.com/news-201801-what-is-the-role-and-generation-of-csr-an ...