前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >SpringBoot集成Thymeleaf模板

SpringBoot集成Thymeleaf模板

作者头像
JavaEdge
发布2018-04-28 16:25:50
7200
发布2018-04-28 16:25:50
举报
文章被收录于专栏:JavaEdge

1 创建一个maven工程,这个应该都会

2 pom文件加入下面内容即可(版本号自己改

代码语言:javascript
复制
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

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

3 写一个入口类

4 写个home.html

5 在工程的resources目录下创建一个application.properties文件,这个文件是spring-boot用来配置一些工程属性用的

代码语言:javascript
复制
# 配置服务器端口,默认是8080,可以不用配置
server.port=8080
# 模板配置
# 这个开发配置为false,避免改了模板还要重启服务器
spring.thymeleaf.cache=false
# 这个是配置模板路径的,默认就是templates,可不用配置
spring.thymeleaf.prefix=classpath:/templates/
# 这个可以不配置,检查模板位置
spring.thymeleaf.check-template-location=true
# 下面3个不做解释了,可以不配置
spring.thymeleaf.suffix=.html
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html

# 模板的模式
spring.thymeleaf.mode=HTML5
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018.01.31 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1 创建一个maven工程,这个应该都会
  • 2 pom文件加入下面内容即可(版本号自己改
  • 3 写一个入口类
  • 4 写个home.html
  • 5 在工程的resources目录下创建一个application.properties文件,这个文件是spring-boot用来配置一些工程属性用的
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档