这篇文章主要介绍了springboot2.1.7整合thymeleaf代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
<强> 1。在pom里面添加thymeleaf依赖
强>
& lt; !——thymeleaf祝辞 & lt; dependency> & lt; groupId> org.springframework.boot & lt; artifactId> spring-boot-starter-thymeleaf & lt;/dependency> & lt; !——使用springboot的thymeleaf模板时默认会对HTML进行严格的检查,导致当你的标签没有闭合时就会通不过,nekohtml这个依赖可以解决这一问题——比; & lt; dependency> & lt; groupId> nekohtml & lt; artifactId> nekohtml & lt; version> $ {nekohtml.version} & lt;/version> & lt;/dependency>
<强> 2。添加application.properties配置强>
spring.thymeleaf.prefix=类路径://模板 spring.thymeleaf.check-template-location=true spring.thymeleaf.suffix=. html spring.thymeleaf.encoding=utf - 8 spring.thymeleaf.servlet.content-type=text/html HTML5 spring.thymeleaf.mode=spring.thymeleaf.cache=false spring.resources.chain.strategy.content.enabled=true spring.resources.chain.strategy.content.paths=/* *
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。