(七)SpringBoot模板引擎Freemaker、thymeleaf

一、Freemaker

1.pom 文件添加


2.配置文件.properties添加相关配置信息


3.创建Controller


4.创建页面


二、thymeleaf

1.pom添加

<dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-thymeleaf</artifactId>

</dependency>

2.配置文件.properties添加相关配置信息

web.upload-path=****

spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/test/,file:${web.upload-path},classpath:/templates/


3.创建Controller


4.创建html

一定要以这种方式获取 <h1 th:text="${setting.name}">测试内容</h1>,而Freemaker 是这种方式获取的 <h1>${setting.domain} </h1> 记得一定要分清楚。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容