mvc-外文翻译

上传人:go****e 文档编号:134408336 上传时间:2020-06-05 格式:DOC 页数:20 大小:200.22KB
返回 下载 相关 举报
mvc-外文翻译_第1页
第1页 / 共20页
mvc-外文翻译_第2页
第2页 / 共20页
mvc-外文翻译_第3页
第3页 / 共20页
mvc-外文翻译_第4页
第4页 / 共20页
mvc-外文翻译_第5页
第5页 / 共20页
点击查看更多>>
资源描述

《mvc-外文翻译》由会员分享,可在线阅读,更多相关《mvc-外文翻译(20页珍藏版)》请在金锄头文库上搜索。

1、Strutsan open-source MVC implementationThis article introduces Struts, a Model-View-Controller implementation that uses servlets and JavaServer Pages (JSP) technology. Struts can help you control change in your Web project and promote specialization. Even if you never implement a system with Struts,

2、 you may get some ideas for your future servlets and JSP page implementation.IntroductionKids in grade school put HTML pages on the Internet. However, there is a monumental difference between a grade school page and a professionally developed Web site. The page designer (or HTML developer) must unde

3、rstand colors, the customer, product flow, page layout, browser compatibility, image creation, JavaScript, and more. Putting a great looking site together takes a lot of work, and most Java developers are more interested in creating a great looking object interface than a user interface. JavaServer

4、Pages (JSP) technology provides the glue between the page designer and the Java developer. If you have worked on a large-scale Web application, you understand the term change. Model-View-Controller (MVC) is a design pattern put together to help control change. MVC decouples interface from business l

5、ogic and data. Struts is an MVC implementation that uses Servlets 2.2 and JSP 1.1 tags, from the J2EE specifications, as part of the implementation. You may never implement a system with Struts, but looking at Struts may give you some ideas on your future Servlets and JSP implementations.Model-View-

6、Controller (MVC)JSP tags solved only part of our problem. We still have issues with validation, flow control, and updating the state of the application. This is where MVC comes to the rescue. MVC helps resolve some of the issues with the single module approach by dividing the problem into three cate

7、gories: ModelThe model contains the core of the applications functionality. The model encapsulates the state of the application. Sometimes the only functionality it contains is state. It knows nothing about the view or controller. ViewThe view provides the presentation of the model. It is the look o

8、f the application. The view can access the model getters, but it has no knowledge of the setters. In addition, it knows nothing about the controller. The view should be notified when changes to the model occur. ControllerThe controller reacts to the user input. It creates and sets the model. MVC Mod

9、el 2The Web brought some unique challenges to software developers, most notably the stateless connection between the client and the server. This stateless behavior made it difficult for the model to notify the view of changes. On the Web, the browser has to re-query the server to discover modificati

10、on to the state of the application.Another noticeable change is that the view uses different technology for implementation than the model or controller. Of course, we could use Java (or PERL, C/C+ or what ever) code to generate HTML. There are several disadvantages to that approach: Java programmers

11、 should develop services, not HTML. Changes to layout would require changes to code. Customers of the service should be able to create pages to meet their specific needs. The page designer isnt able to have direct involvement in page development. HTML embedded into code is ugly. For the Web, the cla

12、ssical form of MVC needed to change. Figure 1 displays the Web adaptation of MVC, also commonly known as MVC Model 2 or MVC 2. Figure 1. MVC Model 2Struts, an MVC 2 implementationStruts is a set of cooperating classes, servlets, and JSP tags that make up a reusable MVC 2 design. This definition impl

13、ies that Struts is a framework, rather than a library, but Struts also contains an extensive tag library and utility classes that work independently of the framework. Figure 2 displays an overview of Struts. Figure 2. Struts viewStruts overview l Client browser An HTTP request from the client browse

14、r creates an event. The Web container will respond with an HTTP response. l ControllerThe Controller receives the request from the browser, and makes the decision where to send the request. With Struts, the Controller is a command design pattern implemented as a servlet. The struts-config.xml file c

15、onfigures the Controller. l Business logicThe business logic updates the state of the model and helps control the flow of the application. With Struts this is done with an Action class as a thin wrapper to the actual business logic. l Model stateThe model represents the state of the application. The

16、 business objects update the application state. ActionForm bean represents the Model state at a session or request level, and not at a persistent level. The JSP file reads information from the ActionForm bean using JSP tags. l ViewThe view is simply a JSP file. There is no flow logic, no business logic, and no model information - just tags. Tags are one of the things that make Struts uni

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 幼儿/小学教育 > 其它小学文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号