Spring JSP MVC和Thymeleaf MVC之间的区别 [英] Difference between spring JSP MVC and Thymeleaf MVC

查看:755
本文介绍了Spring JSP MVC和Thymeleaf MVC之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

spring JSP MVC和Thymeleaf MVC有什么区别?哪一种是春季网页设计的最佳方法?

What is the difference between spring JSP MVC and Thymeleaf MVC? Which one is best way for spring web design ?

推荐答案

它们都是Spring MVC的视图层.首先,最基本的区别是文件扩展名. (.jsp& .html)

Both of them are view layers of Spring MVC. Firstly, the very basic difference is the file extensions. (.jsp & .html)

Branislav是正确的,JSP不是模板引擎.它被编译为servlet,然后servlet正在提供Web内容.另一方面,Thymeleaf是一个模板引擎,它提取HTML文件,对其进行解析,然后生成要提供的Web内容.

Branislav in the comments is right, JSP is not a template engine. It's compiled to the servlet and then the servlet is serving web content. On the other hand, Thymeleaf is a template engine which takes the HTML file, parses it and then produces web content which is being served.

  • Thymeleaf与JSP视图进行比较时,它更像是HTML样式的视图.

  • Thymeleaf is more like an HTML-ish view when you compare it with JSP views.

我们可以在thymeleaf中使用原型代码:

We can use prototype code in thymeleaf : http://www.dineshonjava.com/2015/01/thymeleaf-vs-jsp-spring-mvc-view-layer.html#.WEkLzLKLTig

由于它是HTML风格的代码,因此百里香叶代码更具可读性(当然,您可以将其打乱并创建不可读的代码,但是最后,与.jsp进行比较时,它将更具可读性文件)

Since it is more HTML-ish code, thymeleaf codes are more readable (of course you can disrupt it and create unreadable codes, but at the end, it will be more readable when you compare it with .jsp files)

标准方言(表达式语言)比JSP表达式语言

Standard Dialect (The expression language) is much more powerful than JSP Expression Language

如果我们把所有这些都放在边缘,那么百里香是最慢的一种.

If we put all this to an edge, thymeleaf is the slow one here.

我建议您看看以下文档: http://www. thymeleaf.org/doc/articles/thvsjsp.html

I would suggest you to take a look at this doc : http://www.thymeleaf.org/doc/articles/thvsjsp.html

这篇关于Spring JSP MVC和Thymeleaf MVC之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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