freemarkder和thymeleaf都是java的模板引擎,这里只介绍这两种模板引擎如何在sprongboot中配置:

1. freemarkder

1.1 在pom.xml中添加依赖包

    <!-- 集成freemarker -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>

1.2 在配置文件application.properties中添加配置

# ================================================
# FreeMarker配置
# ================================================
# 是否开启模板缓存
spring.freemarker.cache=true
# 编码格式
spring.freemarker.charset=UTF-8
# 模板的媒体类型设置
spring.freemarker.content-type=text/html
# 前缀设置 默认为 ""
spring.freemarker.prefix=
# 后缀设置 默认为 .ftl
spring.freemarker.suffix=.ftl
#spring.freemarker.allow-request-override=false
#spring.freemarker.check-template-location=true
#spring.freemarker.expose-request-attributes=false
#spring.freemarker.expose-session-attributes=false
#spring.freemarker.expose-spring-macro-helpers=false
#spring.freemarker.request-context-attribute=
#spring.freemarker.template-loader-path=classpath:/templates/
#spring.freemarker.view-names=

2. thymeleaf

2.1 在pom.xml中添加依赖包

    <!-- 集成thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

2.2 添加配置文件

# ================================================
# Thymeleaf配置
# ================================================
# 是否启用thymeleaf模板解析
spring.thymeleaf.enabled=true
# 是否开启模板缓存(建议:开发环境下设置为false,生产环境设置为true)
spring.thymeleaf.cache=false
# Check that the templates location exists.
spring.thymeleaf.check-template-location=true
# 模板的媒体类型设置,默认为text/html
spring.thymeleaf.content-type=text/html
# 模板的编码设置,默认UTF-8
spring.thymeleaf.encoding=UTF-8
# 设置可以被解析的视图,以逗号,分隔
#spring.thymeleaf.view-names=
# 排除不需要被解析视图,以逗号,分隔
#spring.thymeleaf.excluded-view-names=
# 模板模式设置,默认为HTML5
#spring.thymeleaf.mode=HTML5
# 前缀设置,SpringBoot默认模板放置在classpath:/template/目录下
spring.thymeleaf.prefix=classpath:/templates/
# 后缀设置,默认为.html
spring.thymeleaf.suffix=.html
# 模板在模板链中被解析的顺序
#spring.thymeleaf.template-resolver-order=

springboot集成模板引擎freemarker和thymeleaf的更多相关文章

  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:Java模板引擎Thymeleaf介绍

    Thymeleaf是一款用于渲染XML/XHTML/HTML5内容的模板引擎.类似JSP,Velocity,FreeMaker等,它也可以轻易的与Spring MVC等Web框架进行集成作为Web应用 ...

  5. 实现一个代码自动生成(一):模板引擎Freemarker

    目录 前言 模板引擎FreeMarker 前言 在现在的开发当中,代码生成已经是必不可少的一个功能,每个公司都会有自己的一套定制的项目骨架,而实现代码自动生成,模板引擎是必不可少的,所以在这篇博客中, ...

  6. Java模板引擎Freemarker

    Java模板引擎Freemarker 1.取值(插值)指令 2.逻辑指令:if.switch 3.字符串.集合操作 4.自定义函数 5.list排序内建函数.常用指令 6.自定义指令 7.freema ...

  7. SpringBoot第九集:整合JSP和模板引擎Freemarker/Thymeleaf(2020最新最易懂)

    SpringBoot第九集:整合JSP和模板引擎(2020最新最易懂) 当客户通过前端页面提交请求后,我们以前是怎么做的?后端接收请求数据,处理请求,把响应结果交给模板引擎JSP,最后将渲染后的JSP ...

  8. SpringBoot系列:Spring Boot使用模板引擎FreeMarker

    一.Java模板引擎 模板引擎(这里特指用于Web开发的模板引擎)是为了使用户界面与业务数据(内容)分离而产生的,它可以生成特定格式的文档,用于网站的模板引擎就会生成一个标准的HTML文档. 在jav ...

  9. Spring Boot (三)模板引擎FreeMarker集成

    一.FreeMaker介绍 FreeMarker是一款免费的Java模板引擎,是一种基于模板和数据生成文本(HMLT.电子邮件.配置文件.源代码等)的工具,它不是面向最终用户的,而是一款程序员使用的组 ...

随机推荐

  1. javascript - 字符串比较

    1. sort是排序根据字符的ASCIll码排序的,不分字符串或其它元素(仅适用于数组) 2. split是将字符串转为数组形式 3. join是将数组转为字符串形式 4. indexOf找到元素后返 ...

  2. UNIX网络编程读书笔记:poll函数

    poll函数提供的功能与select类似,不过在处理流设备时,它能够提供额外的信息. poll函数原型 #include <poll.h> int poll(struct pollfd * ...

  3. 小贝_redis高级应用-公布与订阅

    redis高级应用-公布与订阅 一.公布与订阅(pub/sub)功能 二.公布与订阅(pub/sub)机制 三.redis公布与订阅(pub/sub)的实现 一.公布与订阅(pub/sub)功能 Pu ...

  4. XCODE修改IOS应用的名称

    原地址:http://zengwu3915.blog.163.com/blog/static/2783489720136210252843/ 首先在左侧选择你的目标组中的项目文件.在中间选择“生成”选 ...

  5. android KK版本号收到短信后,点亮屏的操作

    alps/packages/apps/mms/src/comandroid\mms\transation\MessagingNotification.java private static void ...

  6. vb 获取打印机名称

    Const HKLM = &H80000002 '定义根键常数 '其他常用根键 Const HKCR = &H80000000 , Const HKCU = &H8000000 ...

  7. openerp在ubuntu中查看日志

    sudo su - openerp -s /bin/bash less /var/log/openerp/openerp-server.log

  8. asp.net MVC 视图文件(cshtml/vbhtml)变更编译过程示范

    更改cshtml文件的时候 并不会触发程序重新启动,而是进入了编译状态  csc.exe进程启动. 非阻塞的方式进行等待,延时等待. 示范程序:http://pan.baidu.com/s/1skDY ...

  9. Linux命令-目录处理命令:rm

    rm grub.conf 删除当前目录中grub.conf文件 (最好是先复制一个文件,然后再删除,这样保险) rm -f grub.conf 强制删除当前目录中的grub.conf文件 (不需要确认 ...

  10. 快速掌握Gif动态图实现代码

    版权声明:本文为博主原创文章,未经博主允许不得转载. 前言:Gif一种动态图片,网上有很多制作这个的工具,包括PS都有,但作为一名程序员,我觉得如果自己通过编写代码把它实现,不但是对代码的掌握与复习, ...