Spring Boot中的HTML模板类似于play框架 [英] HTML templates in spring boot similar to play framework

查看:157
本文介绍了Spring Boot中的HTML模板类似于play框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾为Scala使用PlayFramework.现在,我第一次开始使用Spring(Spring Boot).是使HTML模板类似于Play框架的任何方法.例如将HTML内容传递到主要的(main.scala.html)HTML文件中.

I have worked with PlayFramework for Scala. Now I am starting with Spring (Spring Boot) for the first time. Is their any way to make HTML templates similar to Play framework. e.g. passing HTML content into a main(main.scala.html) HTML file.

推荐答案

Spring框架不会强迫您使用任何特定的视图技术.您可以使用任何可以集成的东西.该主题在文档您可以在其中阅读有关热门选择的详细信息.但是,最受欢迎的是Thymeleaf,它在分离为一个独立项目之前曾经是Spring MVC的一部分.您可以在入门指南中找到有关如何将其与Spring Boot结合使用的清晰示例. .

Spring framework does not force you to use any particular view technology. You can use anything that can be integrated. The topic is covered in 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.

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

The templates in Play framework created using Twirl framework are converted into Scala code. You simply pass the data model via template parameter list, just like you do with any method.

在Spring框架中,将要公开的所有日期都放在所谓的模型映射中,该模型映射是简单的键值存储.在视图技术中,您可以使用相应的键来引用这些值.

In Spring framework you put all date that you want to expose to your view in a so-called model map, which is a simple key-value storage. In the view technology you refer the values using corresponding keys.

这篇关于Spring Boot中的HTML模板类似于play框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆