> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/spring-boot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/spring-boot/iv.-spring-boot-features/27.-developing-web-applications/27.1.-the-spring-web-mvc-framework/27.1.10.-template-engines.md).

# 27.1.10. 模板引擎

正如REST web服务，你也可以使用Spring MVC提供动态HTML内容。Spring MVC支持各种各样的模板技术，包括Thymeleaf, FreeMarker和JSPs，很多其他的模板引擎也提供它们自己的Spring MVC集成。

Spring Boot为以下的模板引擎提供自动配置支持：

* [FreeMarker](http://freemarker.org/docs/)
* [Groovy](http://beta.groovy-lang.org/docs/groovy-2.3.0/html/documentation/markup-template-engine.html)
* [Thymeleaf](http://www.thymeleaf.org/)
* [Mustache](http://mustache.github.io/)

**注**：由于在内嵌servlet容器中使用JSPs存在一些[已知的限制](https://github.com/jack80342/spring-boot/tree/25350df33f8edd68b50ff6f6e1258c9df4f67d67/IV.%20Spring%20Boot%20features/27.4.5.%20JSP%20limitations.md)，所以建议尽量不使用它们。

使用以上引擎中的任何一种，并采用默认配置，则模块会从`src/main/resources/templates`自动加载。

**注**：IntelliJ IDEA根据你运行应用的方式会对classpath进行不同的排序。在IDE里通过main方法运行应用，跟从Maven，或Gradle，或打包好的jar中运行相比会导致不同的顺序，这可能导致Spring Boot不能从classpath下成功地找到模板。如果遇到这个问题，你可以在IDE里重新对classpath进行排序，将模块的类和资源放到第一位。或者，你可以配置模块的前缀为`classpath*:/templates/`，这样会查找classpath下的所有模板目录。
