为了账号安全,请及时绑定邮箱和手机立即绑定

SpringBoot集成Thymeleaf模板

标签:
SpringBoot

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

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

    <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用来配置一些工程属性用的

# 配置服务器端口,默认是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



作者:芥末无疆sss
链接:https://www.jianshu.com/p/a34f7d330d5d
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

举报

0/150
提交
取消