HTML templates in spring boot similar to play framework

…衆ロ難τιáo~ 提交于 2019-12-11 04:55:51

问题


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.


回答1:


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.

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.

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.



来源:https://stackoverflow.com/questions/41823295/html-templates-in-spring-boot-similar-to-play-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!