本文介绍了Java Spring MVC模板引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

Spring中有什么模板引擎,类似于laravel中的Blade?

我是Spring的新手,我搜索了模板引擎,但是只发现了Jtwig,尽管它似乎更多是一组功能.

我需要像刀片一样的模板来生成带有页眉,内容,页脚,包括其他视图等的模板.谢谢

解决方案

尝试胸腺.它应该是JSP的后继者(现在认为已过时).

有关如何将其与Spring集成的信息,请参见教程.甚至Spring团队本身也认可Thymeleaf .

要查看实际的Thymleaf布局,请参见此页面.

>

偷窥

main.html

...
<div th:replace="fragments/footer :: footer">
    footer placeholder text to be replaced
</div>

fragments/footer.html

<!DOCTYPE html>
<html>
  <head>
    ...
  </head>
  <body>
    <div th:fragment="footer">
      actual footer text
    </div>
  </body>
</html>

What template engine is in Spring, which is similar to Blade in laravel?

I am new to Spring, I searched templating engines, but have only found Jtwig, although it seems more a set of functions.

I need that like blade, to generate templates with the header, content, footer, include other views, etc.Thanks

解决方案

Try Thymeleaf. It is supposed to be the successor of JSP (now considered outdated).

See this tutorial on how to integrate it with Spring. Even the Spring team themselves are endorsing Thymeleaf.

To see Thymleaf layouting in action, see this page.


Sneak peek

main.html

...
<div th:replace="fragments/footer :: footer">
    footer placeholder text to be replaced
</div>

fragments/footer.html

<!DOCTYPE html>
<html>
  <head>
    ...
  </head>
  <body>
    <div th:fragment="footer">
      actual footer text
    </div>
  </body>
</html>

这篇关于Java Spring MVC模板引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 13:49