《计算机专业毕业论文外文翻译14》由会员分享,可在线阅读,更多相关《计算机专业毕业论文外文翻译14(21页珍藏版)》请在金锄头文库上搜索。
1、大学毕业设计(论文) 第- 1 -页附录附录 A A 外文原文外文原文( (出处:出处: MalcolmMalcolm Davis.Davis. Struts-anStruts-an open-sourceopen-source MVCMVC implementationimplementationJ.J. IBMIBM SystemsSystems Journal,Journal, 2006,44(2):33-37.)2006,44(2):33-37.)Strutsan open-source MVC implementationMalcolm DavisThis article intro
2、duces 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, you may get some ideas for your future servlets and JSP
3、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 understand colors, the customer, product flow, page layout, b
4、rowser 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 Pages (JSP) technology provides the glue between the page
5、 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 logic and data. Struts is an MVC implementation that uses
6、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-Controller (MVC)JSP tags solved only part of our problem.
7、 We still have issues with validation, flow control, and updating the state of the application. This is where MVC comes to the 大学毕业设计(论文) 第- 2 -页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 co
8、re 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. View The view provides the presentation of the model. It is the look of the application. The view can acces
9、s 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. Controller The controller reacts to the user input. It creates and sets the model. MVC Model 2The Web brought some unique chal
10、lenges 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 modification to the state of the application.A
11、nother 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 should develop services, not HTML.
12、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 classical form of MVC needed to change.
13、 Figure 4 displays the Web adaptation of MVC, also commonly known as MVC Model 2 or MVC 2. Struts details大学毕业设计(论文) 第- 3 -页Displayed in Figure 6 is a stripped-down UML diagram of the org.apache.struts.action package. Figure 6 shows the minimal relationships among ActionServlet (Controller), ActionFo
14、rm (Form State), and Action (Model Wrapper). Figure 6. 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 set the state of the UserActionForm using corresponding fields from the HttpServletRequest. No more
15、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 UserActionForm before passing it to the business wrapper UserAction. Before passing it to the Action class,
16、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 business objects, where the validation might be different. Validation of the state might be better in the UserAction class. The UserActionForm can be maintained at a session level. Notes: The struts-config.xml file controls which