信息科学与工程学院毕业设计科技文献翻译

上传人:小** 文档编号:49048050 上传时间:2018-07-22 格式:DOC 页数:12 大小:142.50KB
返回 下载 相关 举报
信息科学与工程学院毕业设计科技文献翻译_第1页
第1页 / 共12页
信息科学与工程学院毕业设计科技文献翻译_第2页
第2页 / 共12页
信息科学与工程学院毕业设计科技文献翻译_第3页
第3页 / 共12页
信息科学与工程学院毕业设计科技文献翻译_第4页
第4页 / 共12页
信息科学与工程学院毕业设计科技文献翻译_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《信息科学与工程学院毕业设计科技文献翻译》由会员分享,可在线阅读,更多相关《信息科学与工程学院毕业设计科技文献翻译(12页珍藏版)》请在金锄头文库上搜索。

1、信息科学与工程学院毕业设计科技文献翻译信息科学与工程学院毕业设计科技文献翻译StrutsAn Open-source MVC ImplementationStruts一种开源 MVC 的实现姓 名 张张 三三 丰丰 学 号 2014000020140000 年 级 20142014 级级 专 业 计算机科学与技术计算机科学与技术 指导教师 李李 双双 双双 2018 年 3 月 StrutsAn Open-source MVC ImplementationThis article introduces Struts, a Model-View-Controller implementation

2、 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, you may get some ideas for your future servlets and JSP page implementation1. IntroductionIf you have worked

3、 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 logic and data. Struts is an MVC implementation that uses Servlets 2.2 and JSP 1.1 tags, from the J2EE specifi

4、cations, 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.2. Model-View-Controller (MVC)JSP tags solved only part of our problem. We still have issues with validation, flow contr

5、ol, 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 categories: Model The model contains the core of the applications functionality. The model encapsulates the st

6、ate of the application. Sometimes the only functionality it contains is state. It knows nothing about the view or controller. View The 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 add

7、ition, it knows nothing about the controller. The view should be notified when changes to the model occur. Controller The controller reacts to the user input. It creates and sets the model. 3. Struts Summary3.1 Struts detailsDisplayed in Figure 1 is a stripped-down UML diagram of the org.apache.Stru

8、ts.action package. Figure 6 shows the minimal relationships among ActionServlet (Controller), ActionForm (Form State), and Action (Model Wrapper). Figure 1 UML diagram of the relationship of the Command (ActionServlet) to the Model (Action if not, it will create an instance of the class. Struts will

9、 set the state of the UserActionForm using corresponding fields from the HttpServletRequest. No more dreadful request.getParameter() calls. For instance, the Struts framework will take fname from request stream and call UserActionForm.setFname(). The Struts framework updates the state of the UserAct

10、ionForm before passing it to the business wrapper UserAction. Before passing it to the Action class, Struts will also conduct form state validation by calling the validation() method on UserActionForm. Note: This is not always wise to do. There might be ways of using UserActionForm in other pages or

11、 business objects, where the validation might be different. Validation of the state might be better in the UserAction class. 3.1.3 The Action class The Action class is a wrapper around the business logic. The purpose of Action class is to translate the HttpServletRequest to the business logic. To us

12、e Action, subclass and overwrite the process() method. The ActionServlet (Command) passes the parameterized classes to ActionForm using the perform() method. Again, no more dreadful request.getParameter() calls. By the time the event gets here, the input form data (or HTML form data) has already bee

13、n translated out of the request stream and into an ActionForm class.3.1.4 The Error classes ActionError encapsulates an individual error message. ActionErrors is a container of ActionError classes that the View can access using tags. ActionErrors is Struts way of keeping up with a list of errors.Fig

14、ure 2 UML diagram of the relationship of the Command (ActionServlet) to the Model (Action)3.1.5 The ActionMapping class An incoming event is normally in the form of an HTTP request, which the servlet Container turns into an HttpServletRequest. The Controller looks at the incoming event and dispatche

15、s the request to an Action class. The Struts-config.xml determines what Action class the Controller calls. The Struts-config.xml configuration information is translated into a set of ActionMapping, which are put into container of ActionMappings. (If you have not noticed it, classes that end with s a

16、re containers)The ActionMapping contains the knowledge of how a specific event maps to specific Actions. The ActionServlet (Command) passes the ActionMapping to the Action class via the perform() method. This allows Action to access the information to control flow.3.2 Struts pros 3.2.1 Use of JSP tag mechanism The tag feature promotes reusable code and abstracts Java code from the JSP file. This feature all

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 商业/管理/HR > 管理学资料

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