【正文】
ing Microsoft MVC, Microsoft Press.4. Fowler, M., 2003. Patterns of Enterprise Application Architecture, AddisonWesley, Boston.5. Gamma, E., Helm, R., Johnson, R., Vlissides, J.,1995. Design Patterns, Addison Wesley, Reading, MA.6. Goldberg, A., Robson, D., 1985. Smalltalk80 : the language and its implementation, AddisonWesley.7. Krasner, ., Pope, ., 1988. A Cookbook for Using the ModelView Controller User Interface Paradigm in Smalltalk80. Journal of ObjectOriented Programming, 1(3), 2649.8. Mahmoud, Q., 2003. Servlets and JSP Pages Best Practices, 9. Thomas, D., Hansson, ., 2007. Agile Web Development with Rails. The Pragmatic Bookshelf.THE MVCWEB DESIGN PATTERNRalph F. GroveDepartment of Computer Science, James Madison University, Harrisonburg, VA USAgroverfEray OzkanDepartment of Computer Science, James Madison University, Harrisonburg, VA USAozkanexKeywords: web, web framework, design patterns, model view controller patternAbstract: The ModelViewController design pattern is cited as the architectural basis for many web development frameworks. However, the version of MVC used for web development has changed as it has evolved from the original Smalltalk MVC. This paper presents an analysis of those changes, and proposes a separate WebMVC pattern that more accurately describes how MVC is implemented in web frameworks.1 INTRODUCTIONRails is a web application framework developed for use with the Ruby programming languages (Thomas and Hansson, 2007). HTTP requests are handled in Rails through a central router that directs requests to the appropriate ActionController class and method within the controller ponent. ActionController objects are responsible for filtering request parameters, for orchestrating transactions by invoking methods of appropriate model elements, and for arranging the appropriate view response. ActionControllers also arrange for view elements to have access to data from the model. The controller elements are also responsible for web session management, including cookie management. The user interface (view ponent) is presented through dynamic document templates that are standard HTML documents with embedded Ruby scripts, similar to ASP, PHP, JSP, etc. The model is not clearly defined: All of the frameworks lack a clear definition of the Model ponent. It is assumed to involve application logic and data management, but there is no clear structure to define the model or to cleanly separate it from the controller. l 167。 Modelview: View elements may query the model to obtain information to be displayed to the user l 167。 Action handlers: receive request parameters。 No 11 viewcontroller correspondence: In the original MVC, each view element has a unique controller element that is defined for that view element alone. l 167。這個可能分離的關(guān)注點,但是通過給用戶提供更快的響應(yīng)來提高了應(yīng)用程序的效率。MVCWeb反映了MVC設(shè)計模式已經(jīng)在web框架中實現(xiàn)了的革命性的變化。相反,控制器決定視圖的行為取決于模型的事務(wù)處理的結(jié)果??刂破骺刂破髟匾藏撠焪eb會話管理,包括cookie管理。這就使得當你修改或替換某一個組件時,無需修改甚至無需解會其他部分。模型(model)組件封裝了應(yīng)用程序的特定域的結(jié)構(gòu)和功能,其本質(zhì)就是包括了應(yīng)用程序的狀態(tài)以及改變這種狀態(tài)的操作。本文介紹了對這些變化的分析,并提出了一種獨立的WebMVC模式,用于更準確的描述MVC是如何在web框架中實現(xiàn)的。視圖也有可能是分層的,它由一些更小的(子視圖)元素構(gòu)成??刂破髫撠熖幚韨魅氲恼埱?,由模型策劃事務(wù)處理,為后來的視圖元素準備數(shù)據(jù),同時激活視圖元素使其產(chǎn)生響應(yīng)。Apache Struts2 框架是基于Java企業(yè)版(J2EE)和Java服務(wù)器頁面( 技術(shù))。l 控制器元素負責數(shù)據(jù)驗證:交易數(shù)據(jù)驗證本質(zhì)上是一個模型函數(shù)。MVCWeb模式的組件之間的交互有以下方式:l 模型視圖:視圖元素會查詢模型以獲取信息用來顯示給用戶l 模型控制器:控制器方法元素要求模型元素傳送請求交易。The ModelViewController (MVC) design pattern is cited as the basis for the architecture of several web application frameworks, such as ASP .Net, Rails, and Struts. The MVC pattern was originally implemented in the Smalltalk80 programming environment developed at Xerox PARC (Goldberg and Robson, 1985). As it has been adapted for web frameworks the MVC pattern has evolved in different ways, resulting in implementations that differ significantly from each other and from the original Smalltalk implementation. View elements can access the model ponent as necessary to obtain data for presentation. The Rails model ponent includes elements that encapsulate application logic and transaction processing (ActiveModel), and an object relational mapping scheme (ActiveRecord) that associates each database table with a model element. The model also includes ActiveResource elements that provide access to external resources. Model classes are instantiated on than a persistent model ponent as envisioned in the original MVC, the web frameworks instantiate model objects as nee