1.Freemarker Introduction
Freemarker is one of the three major mainstream template engines, with jsp,velocity and called the "Three Musketeers". 2.Freemarker Integration Solutions
① adding dependencies in Pom.xml
<!--freemarker Dependent-
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
Configuration of ②freemarker in Application.properities
# Freemarker (freemarkerautoconfiguration)
Spring.freemarker.allow-request-override=false
Spring.freemarker.allow-session-override=false
spring.freemarker.cache=true
Spring.freemarker.check-template-location=true
spring.freemarker.content-type=text/html
Spring.freemarker.enabled=true
Spring.freemarker.expose-request-attributes=false
Spring.freemarker.expose-session-attributes=false
spring.freemarker.expose-spring-macro-helpers=true
Spring.freemarker.prefer-file-system-access=true
spring.freemarker.suffix=.html
spring.freemarker.template-loader-path=classpath:/ftl/
spring.freemarker.settings.template_update_delay=0
Spring.freemarker.settings.default_encoding=utf-8
spring.freemarker.settings.classic_compatible= True
spring.freemarker.order=1
Of course, the suffix of the access resources here can also be. FTL, this is the Orthodox Freemarker
Spring.freemarker.suffix=.ftl
Here the author of the HTML master better, so the preferred choice of HTML;
③ Create the FTL directory under resources based on the path configuration and new test.html
The test.html code is as follows:
<! doctype>
④ Edit Test Controller
@RequestMapping ("Ftl/test") public
String TESTFTL (Modelmap model) {
Model.addattribute ("name", " Freemarker template Engine ");
return "Test";
}
Note that the outermost control layer annotations can only be used @ @controller;
⑤ Access Test
All right, I'm Zhang Xing Zhaoyuan. Welcome to the BO Master Technology Exchange Group, Group No.: 313145288