加入收藏 | 设为首页 | 会员中心 | 我要投稿 阜阳站长网 (https://www.0558zz.com/)- 科技、建站、内容创作、云计算、网络安全!
当前位置: 首页 > 编程开发 > Java > 正文

java – MVC和MVC Model2之间的实际区别是什么?

发布时间:2020-07-09 01:41:26 所属栏目:Java 来源:互联网
导读:只是我想知道MVC和MVC Model2在开发中的实际区别是什么 说明以前的答案(并从 this article添加说明): MVC2是一个abuse of language实际上引用了JSP Model 2架构,而不是JSP Model 1: The first Java technology for server-side web development was the ser

只是我想知道MVC和MVC Model2在开发中的实际区别是什么

解决方法

说明以前的答案(并从 this article添加说明):

MVC2是一个abuse of language实际上引用了JSP Model 2架构,而不是JSP Model 1:

The first Java technology for server-side web development was the servlet.
Writing applications with servlets was very similar to writing CGI applications in Perl in that all of the output had to be built up as Strings from within Java code.
This was very tedious and error-prone. It also made it very difficult for web designers with no Java experience to alter the look and feel of the pages generated by servlets.

alt text http://www.javaworld.com/javaworld/jw-12-1999/images/MODEL1_sml.gif

Then came JSP. JSPs,like Microsoft ASPs and like the popular scripting language PHP,treat everything as template text,but allow the insertion of Java code into tags called scriptlets and JSP expressions.
This allowed people to work on server-side applications just as they would with the other popular scripting languages but it had a couple of drawbacks.

  • There was no separation of concerns.
  • One script would hold database code,business logic,HTML markup and any javascript code needed for the final page rendering.
  • Code reuse was difficult as was automated testing.

This came to be known as “Model 1” JSP programming.

07003 was a common technique for separating the various concerns in GUI code invented by Trygve Reenskaug,working on Smalltalk for Zerox.

At some point it became clear that this technique could be adapted to Java EE applications to achieve the same level of separation.
Doing so involves writing the Model layer as Beans or Plain Old Java Objects (POJOs),using servlets as the Controller,and then,when all the heavy lifting is done,forwarding to a JSP to format and markup the results.
Servlet/JSP applications written using and MVC architecture came to be known as Model 2 JSP programming.

alt text http://www.javaworld.com/javaworld/jw-12-1999/images/MODEL2_sml.gif

Because this pattern existed in a different form before being used in servlet/JSP applications,it was sometimes referred to as “MVC2”. This name led to some confusion as it implied that there is an MVC1 for servlet applications,which there is not. It is sufficient just to say MVC.

(编辑:阜阳站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读