MVC1 和 MVC2 有什么区别
我在 jsp-servlet Web 应用程序中使用 MVC 设计模式,想知道 MVC1 和 MVC2 之间的确切区别是什么,有人可以帮忙吗?
编辑新我听说在servlet编程中使用MVC有2个版本,我听说在MVC1中控制器和视图之间存在某种耦合,但在MVC2中它们超越了它,如果有人知道这是否无论是对还是错我都会非常感激。
I am using MVC design pattern in jsp-servlet web application, and want to what is the exact difference between MVC1 and MVC2 , can someone help?
EDIT newly I hear that there is 2 versions of using MVC in servlet programming, I hear that in MVC1 there is kind of coupling between controller and view , but in MVC2 they overtake it, if someone know whether this is right or wrong I'll be very thankful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可能会结合 ASP.NET MVC 阅读此版本,因为该框架存在不同版本。没有mvc模式的2.0版本,只有asp.net MVC框架的2.0版本。
在 jsp servlet 上下文中,请参阅:模型 1 和 模型 2。简而言之:模型 1 没有用于分派请求的控制器,而模型 2 有。
It might be possible that you read this version in connection with asp.net MVC, as there different versions of that framework. There is no version 2.0 of the mvc pattern, just a version 2.0 of the asp.net MVC framework.
In context of jsp servlets see: Model 1 and Model 2. In a nutshell: Model 1 doesn't have a controller to dispatch requests, Model 2 does.
在MVC 1中,控制器和模型都是JSP。而在MVC2中,控制器是servlet,模型是java类。
在 MVC1 中,页面和模型之间存在紧密耦合,因为数据访问通常使用自定义标记或通过 java bean 调用来完成。
在 MVC2 架构中,只有一个控制器接收应用程序的所有请求,并负责采取适当的操作来响应每个请求。
In MVC 1, controller and model,both are JSP. While in MVC2 controller is servlet and model is java class.
In MVC1 there is tight coupling between page and model as data access is usually done using Custom tag or through java bean call.
In MVC2 architecture there is only one controller which receives all the request for the application and is responsible for taking appropriate action in response to each request.
MVC1 是第一代方法,它使用 JSP 页面和 JavaBeans 组件体系结构来实现 Web 的 MVC 体系结构。 HTTP 请求被发送到 JSP 页面,该页面实现控制器逻辑并调用模型获取数据以更新视图。这种方法将控制器和视图功能结合在 JSP 页面中,因此打破了 MVC 范例。 MVC1适合简单的开发和原型设计。然而,不建议认真开发。
MVC2 是 Sun 发明的一个术语,用于描述基于 Web 的应用程序的 MVC 架构,其中 HTTP 请求从客户端传递到控制器 servlet,控制器 servlet 更新模型,然后调用适当的视图渲染器,例如 JSP 技术,它在Turn 从更新的模型渲染视图。
MVC2 方法的标志是将控制器代码与
内容。 (Struts 等表示框架的实现遵循 MVC2 方法)。
这就是我在这里找到的: http://www.theserverside.com/discussions/thread .tss?thread_id=20685
MVC1 was a first generation approach that used JSP pages and the JavaBeans component architecture to implement the MVC architecture for the Web. HTTP requests are sent to a JSP page that implements Controller logic and calls out to the Model for data to update the View. This approach combines Controller and View functionality within a JSP page and therefore breaks the MVC paradigm. MVC1 is appropriate for simple development and prototyping. It is not, however, recommended for serious development.
MVC2 is a term invented by Sun to describe an MVC architecture for Web-based applications in which HTTP requests are passed from the client to a Controller servlet which updates the Model and then invokes the appropriate View renderer-for example, JSP technology, which in turn renders the View from the updated Model.
The hallmark of the MVC2 approach is the separation of Controller code from
content. (Implementations of presentation frameworks such as Struts, adhere to the MVC2 approach).
That's what I found here: http://www.theserverside.com/discussions/thread.tss?thread_id=20685
MVC-1 架构
1) 在 MVC-1 架构中,单个 Web 组件(Servlet/JSP)用作控制器和视图,但对于其他层,则采用单独的 Web 组件......
2) 由于单个组件被视为控制器和视图,因此逻辑是混合的。
MVC-2 架构
1) 在 MVC-2 架构中,单独的组件应该用于单独的层...
2)逻辑没有混合,逻辑之间有清晰的分离......
MVC-1 Architecture
1) In MVC-1 Architecture, single web component(Servlet/JSP) is used as Controller and view but for other layers separate web components are taken....
2) Since, single component is taken as Controller and view, logics are mixed up..
MVC-2 Architecture
1) In MVC-2 Architecture separate components should be taken for separate layers...
2) Logics are not mixed, there is clean separation between the logics....