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 點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優質文章
正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦