springboot整合thymeleaf

1.pom.xml


    org.springframework.boot
    spring-boot-starter-thymeleaf

2.配置文件application.properties

#整合thymeleaf
#关闭缓存,改完页面后就能实时刷新,上生产需改为true
spring.thymeleaf.cache=false
spring.thymeleaf.mode=HTML5
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.content-type=text/html

3.在resources资源文件目录下得有个templates目录:

在html的文件中:

xmlns:th="http://www.thymeleaf.org">

注意:idea建立html文件时候会出现报错

报错org.xml.sax.SAXParseException: 元素类型 "

" 必须由匹配的结束标记 " 终止

需要加上斜杠/标记标签结束

 

你可能感兴趣的:(springboot整合thymeleaf)