Thymeleaf VS JSP

收集了一些 Thymeleaf 与其它技术的比较信息,暂时记下,比较后再决定项目中是否要引入Thymeleaf 模板。


http://forum.spring.io/forum/spring-projects/web/104069-should-i-use-thymeleaf-or-jsp-for-the-html-layer

Should I use Thymeleaf or JSP for the HTML layer?


Nevertheless, it still seems to be in beta, so I'd like to ask: does anyone know it? Anyone there already using it? Any words about advantages/disadvantages with JSP?


官网中 与 jsp 的比较:

http://www.thymeleaf.org/doc/articles/thvsjsp.html


官网中的FAQ:

http://www.thymeleaf.org/faq.html#substitute-jsp

问: Thymeleaf 能否完全替代 JSP 和 JSTL ?

答: 绝对的,不仅可以,而且我们强烈建议您这样做。

原文:

Can Thymeleaf be used as a complete substitute for JSP and JSTL?

Absolutely. Not only it can, but we strongly encourage you to do so. Have a look at our Thymeleaf vs. JSP article if you want to learn how these two technologies compare.



thymeleaf 布局方案示例 header, footer, menu公用代码的重复使用。

http://www.thymeleaf.org/doc/articles/layouts.html



有关于是否使用 thymeleaf 的争论:

https://spring.io/blog/2012/10/30/spring-mvc-from-jsp-and-tiles-to-thymeleaf

-----------------------------

Viacheslav Garmash • a year ago
I would like to note to the users that it is not correct to compare Thymeleaf only to JSP and Tiles. There are much more templating engines on the market for example Velocity and Freemarker to name a few.

The reasoning like: "this framework is more modern than others" is just misleading. Mature frameworks usually have better documentation, tutorials and examples with less bugs in the implementation.

Also please do not forget about some of limitations of the Thymeleaf which they pointed in their FAQ (http://www.thymeleaf.org/faq.h...

"How does Thymeleaf compare with other template engines like Velocity or FreeMarker?": http://www.thymeleaf.org/faq.h...

Thymeleaf developers agree that their framework is more focused on HTML5 only and you can't use it for any other output while Velocity and Freemarker are more versatile and can be used for any text content-type.

"Thymeleaf uses DOM-style parsing of XML. How does that affect memory usage?"
http://www.thymeleaf.org/faq.h...

Thymeleaf developers mention that they use DOM parser which is slow for large documents. Please evaluate size of your source documents and if it is too large then you better stick with Tiles/JSPs which don't have this problem.

Additional advantage of using JSP custom tags or Tiles that you can enable caching for the output to increase performance even further.
---------------------------Langley Viacheslav Garmash • 3 months ago
Hello Viacheslav,
Thanks for the extra info, although I have some suggestions to improve the way you give feedback.
1- The article never states is a comparison article so I'm not sure why its not correct to compare Thymeleaf with only those, if those 2 are exactly the ones the author mentions in the article's title, If you were looking for something else, you can't blame the author, the article is exactly about what the title says.
2- I agree with the fact that the guy says that even though its not wrong, the code is the same as it was 8 years ago, so is that good or not?
3- Your statement about memory issue on thymeleaf sounds misleading too, that issue is when creating Data files with huge amount of data, big data parsed as XML, they are talking about files over 10Mb, I'm not really sure how jsp would fix that, for pages, if you have templates over 10mb you have way bigger problems than your engine.








GitHub上的示例:

https://github.com/thymeleaf/thymeleafexamples-layouts

https://github.com/thymeleaf/thymeleafexamples-stsm

https://doanduyhai.wordpress.com/2012/04/14/spring-mvc-part-iv-thymeleaf-advanced-usage/















你可能感兴趣的:(thymeleaf)