Spring Boot项目整合FreeMarker模板
记录
Apache FreeMarker™ is a *template engine*: a Java library to generate text output (HTML web pages, e-mails, configuration files, source code, etc.) based on templates and changing data. Templates are written in the FreeMarker Template Language (FTL), which is a simple, specialized language (not a full-blown programming language like PHP). Usually, a general-purpose programming language (like Java) is used to prepare the data (issue database queries, do business calculations). Then, Apache FreeMarker displays that prepared data using templates. In the template you are focusing on how to present the data, and outside the template you are focusing on what data to present.
FreeMarker 是一款模模板引擎,一种基于模板和要改变的数据, 并用来生成输出文本(HTML网页,电子邮件,配置文件,源代码等)的通用工具。 它不是面向最终用户的,而是一个Java类库,是一款程序员可以嵌入他们所开发产品的组件。
FreeMarker基于模板和要改变的数据,用来生成输出文本
模板编写为FreeMarker Template Language (FTL)
模板显示已经准备好的数据。在模板中,可以专注于如何展现数据, 而在模板之外可以专注于要展示什么数据。
Spring Boot项目整合FreeMarker模板。
新建项目,在项目中加入Freemarker依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId