HTML spring 中的模板启动类似于播放框架

HTML templates in spring boot similar to play framework

我使用过 Scala 的 PlayFramework。现在我第一次从 Spring (Spring Boot) 开始。他们有什么方法可以制作类似于 Play 框架的 HTML 模板。例如将 HTML 内容传递到主(main.scala.html)HTML 文件中。

Spring 框架不强制您使用任何特定的视图技术。您可以使用任何可以集成的东西。 the documentation where you can read about the details on popular choices. However, the most popular is Thymeleaf, which used to be a part of Spring MVC before separation into an independent project. You can find a clear example on how to use it with Spring Boot in the getting started guide.

中涵盖了该主题

Play框架中使用Twirl框架创建的模板转换为Scala代码。您只需通过模板参数列表传递数据模型,就像您使用任何方法一样。

在 Spring 框架中,您将所有要在视图中公开的日期放在 so-called 模型映射中,这是一个简单的 key-value 存储。在视图技术中,您使用相应的键引用值。