springboot整合常用组件和服务【7】springboot支持thymeleaf

本文详细介绍了在SpringBoot项目中整合Thymeleaf的步骤,包括环境配置、pom.xml文件修改、创建Controller和Entity包、在templates目录下创建HTML模板,以及启动测试的过程。
摘要由CSDN通过智能技术生成

thymeleaf也是一模板技术,与freemarker类似,本文讲述springboot如何整合thymeleaf。

1、环境约束

  • win10 64位操作系统
  • idea2018.1.5
  • maven-3.0.5
  • jdk-8u162-windows-x64

2、前提约束

  • 完成springboot创建web项目 https://www.jianshu.com/p/de979f53ad80
    注意:笔者创建项目的时候约束的包前缀是net.wanho.springboot.thymeleaf,读者可以自行创建包名,只是要注意本文中的代码也要修改包名

3、修改pom.xml

在dependencies标签中加入以下依赖:

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

4、在net.wanho.springboot.thymeleaf包下面创建controller、entity子包

在entity下创建User.java

package net.wanho.springboot.thymeleaf.entity;

public class User {
    private Intege
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值