计算机外文翻译StrutsMVC的一种开放源码实现

上传人:s9****2 文档编号:563753245 上传时间:2022-09-20 格式:DOC 页数:22 大小:199.50KB
返回 下载 相关 举报
计算机外文翻译StrutsMVC的一种开放源码实现_第1页
第1页 / 共22页
计算机外文翻译StrutsMVC的一种开放源码实现_第2页
第2页 / 共22页
计算机外文翻译StrutsMVC的一种开放源码实现_第3页
第3页 / 共22页
计算机外文翻译StrutsMVC的一种开放源码实现_第4页
第4页 / 共22页
计算机外文翻译StrutsMVC的一种开放源码实现_第5页
第5页 / 共22页
点击查看更多>>
资源描述

《计算机外文翻译StrutsMVC的一种开放源码实现》由会员分享,可在线阅读,更多相关《计算机外文翻译StrutsMVC的一种开放源码实现(22页珍藏版)》请在金锄头文库上搜索。

1、 外 文 翻 译学 院: 信息科学与工程学院 专 业: 计算机科学与技术 学生姓名: 宋清云 学生班级: 计算机0801班 学生学号: 080405017 指导教师: 崔文成 指导教师评语指导教师签名:年 月 日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 contro

2、l change in your Web project and promote specialization. Even if you never implement a system with Struts, 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

3、grade school page and a professionally developed Web site. The page designer (or HTML developer) must understand 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 deve

4、lopers are more interested in creating a great looking object interface than a user interface. JavaServer 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-Control

5、ler (MVC) is a design pattern put together to help control change. MVC decouples interface from business logic 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,

6、 but looking at Struts may give you some ideas on your future Servlets and JSP implementations.Model-View-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. MV

7、C helps resolve some of the issues with the single module approach by dividing the problem into three categories: 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 n

8、othing about the view or controller. ViewThe view provides the presentation of the model. It is the look of 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

9、the model occur. ControllerThe controller reacts to the user input. It creates and sets the model. MVC Model 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 mode

10、l to notify the view of changes. On the Web, the browser has to re-query the server to discover modification 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/

11、C+ or what ever) code to generate HTML. There are several disadvantages to that approach: Java programmers 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

12、able to have direct involvement in page development. HTML embedded into code is ugly. For the Web, the classical 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

13、 of cooperating classes, servlets, and JSP tags that make up a reusable MVC 2 design. This definition implies 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 overvi

14、ew of Struts. Figure 2. Struts viewStruts overview l Client browser An HTTP request from the client browser 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

15、 Struts, the Controller is a command design pattern implemented as a servlet. The struts-config.xml file configures 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 business objects update the application state. ActionForm bean represents the Model state at a session or request

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

当前位置:首页 > 办公文档 > 工作计划

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