畢業(yè)設(shè)計(jì)論文 外文文獻(xiàn)翻譯 深入Struts架構(gòu) 中英文對(duì)照_第1頁(yè)
畢業(yè)設(shè)計(jì)論文 外文文獻(xiàn)翻譯 深入Struts架構(gòu) 中英文對(duì)照_第2頁(yè)
畢業(yè)設(shè)計(jì)論文 外文文獻(xiàn)翻譯 深入Struts架構(gòu) 中英文對(duì)照_第3頁(yè)
畢業(yè)設(shè)計(jì)論文 外文文獻(xiàn)翻譯 深入Struts架構(gòu) 中英文對(duì)照_第4頁(yè)
畢業(yè)設(shè)計(jì)論文 外文文獻(xiàn)翻譯 深入Struts架構(gòu) 中英文對(duì)照_第5頁(yè)
已閱讀5頁(yè),還剩25頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、畢業(yè)設(shè)計(jì)外文資料翻譯(譯文)譯文題目: 深入struts架構(gòu) 原文題目: exploring the struts architecture 原文出處: struts kick start exploring the struts architecturethis chapter covers_ introducing application frameworks, mvc, and model 2_ understanding how struts works_ using the struts control flow_ exploring the strengths and weakne

2、sses of struts2.1 talking the talkthis chapter explores the struts framework in depth and highlights the benefits struts can bring to your development efforts. we believe that once you can “talk the talk” of web architecture and design, you will be better equipped to use struts with your own applica

3、tions.with a sound overview of the struts architecture in place, we outline the struts control flow and the way it handles the request-response event cycle. a good understanding of this process makes it much easier to create applications that make the best use of the framework.choosing a web applica

4、tion framework should not be a casual decision. many people will use this book, and especially this chapter, as part of evaluating struts for their project. accordingly, we conclude this chapter with a candid look at the strengths and weaknesses of the struts framework and address concerns regarding

5、 overall performance. struts is designed for professional developers. to make informed decisions, professionals need to be aware of both a tools capabilities and its limitations.2.2 why we need strutstodays web applications are critical components of the corporate mission. as always, development tea

6、ms need to build applications in record time, but they have to build them right and build them to last.java web developers already have utilities for building presentation pages, such as java server pages and velocity templates. we also have mechanisms for handling databasesjdbc and enterprise javab

7、eans (ejbs), for example. but what do we use to put these components together? we have the plumbing and the drywall what else do we need?2.2.1 one step back, three steps forwardin the late 1970s, when graphical user interfaces (guis) were being invented, software architects saw applications as havin

8、g three major parts: the part that manages data, the part that creates screens and reports, and the part that handles interactions between the user and the other subsystems ooram. in the early1980s, the objectworks/smalltalk programming environment introduced this triumvirate as a development framew

9、ork. in smalltalk 80 parlance, the data system is dubbed the model, the presentation system is called the view, and the interaction system is the controller. many modern development environments, including javas swing, use this model/view/controller (mvc) architecture (see figure 2.1) as the foundat

10、ion of their own frameworks.java web developers already have capable tools, such as jdbc and jsp, for consulting the model and creating the view, but wheres the controller for our web applications?2.2.2 enter strutsthe centerpiece of struts is an mvc-style controller. the struts controller bridges t

11、he gap between model and view. the framework also includes other missing pieces developers need to write scalable, leading-edge web applications. struts is a collection of “invisible underpinnings” that help developers turn raw materials like databases and web pages into a coherent application.2.2.3

12、 struts controller componentsthe struts controller is a set of programmable components that allow developers to define exactly how their application interacts with the user. these components view controllermodel figure 2.1 the model/view/controller architecture hide nasty, cumbersome implementation

13、details behind logical names. developers can program these details once, then go back to thinking in terms of what the program does rather than how it does it.users interact with a web application through hyperlinks and html forms. the hyperlinks lead to pages that display data and other elements, s

14、uch as text and images. the forms generally submit data to the application via some type of custom action. as shown in figure 2.2, struts provides components that programmers can use to define the hyperlinks, forms, and custom actions that web applications use to interact with the user. we used thes

15、e components to build a starter application in chapter 1. in chapter 3, we walk through using these components to build another simple application. then, in chapter 4, we provide a detailed overview of configuring these components. later chapters provide more detail about putting each component to u

16、se within your application. in part 4 we demonstrate using the components in the context of working applications. but, since this chapter is the architectural overview, lets go ahead and introduce the major struts components now.note :the struts components are configured via xml. in practice, the co

17、nfiguration elements are an integral part of the struts framework. to help you put it all together, we show a sample of each components xml element as it is introduced.hyperlinksto the application developer, a hyperlink is a path to some resource in the application.this may be a web page or a custom

18、 action. it may also include special parameters. in struts, developers can define a hyperlink as an actionforward.these objects have a logical name and a path property. this lets developers set the path and then refer to the actionforward by name.actionforwards are usually defined in an xml configur

19、ation file that struts reads when the web application loads. struts uses the xml definitions to create the hyperlinks/actionforms html forms/actionforms custom actions/actionforms figure struts configuration, which includes a list of actionforwards. the xml element that would create an actionforward

20、 for a welcome hyperlink might look like this:this element would create an actionform javabean with its name property set to welcome and its path property set to /pages/index.jsp.jsp pages and other components can then refer to the welcome forward. the struts framework will look up the welcome actio

21、nforward bean and retrieve the path to complete the hyperlink. this allows developers to change the destination of a link without changing all the components that refer to that link. in most web applications, details like this are hardcoded into jsp and java code, making changes difficult and prone

22、to error. in a struts application, these details can be changed throughout the application without touching a single page or java class.for more about actionforwards, see chapter 6.html formsthe web protocols, http and html, provide a mechanism for submitting data from a form but leave receiving the

23、 data as an exercise for the developer. the struts framework provides an actionform class, which is designed to handle input from an html form, validate the input, and redisplay the form to the user for correction(when needed), along with any corresponding prompts or messages.actionforms are just ja

24、vabeans with a couple of standard methods to manage the validation and revision cycle. struts automatically matches the javabean properties with the attributes of the html controls. the developer defines the actionform class. struts does the rest.this class will automatically populate the username f

25、ield from a form with an html form element of the same name, as shown here:public final class logonform extends actionform private string username = null;public string getusername() return (this.username);public void setusername(string username) this.username = username;other properties would be add

26、ed for each field of the form. this lets other componentsget what they need from a standard javabean, so everyone does not haveto sift through an http request.the actionform classes are created using normal java classes. the struts configuration refers to the actionform classes through a set of desc

27、riptors: the and elements. the elements are descriptors that the framework uses to identify and instantiate the actionform objects,as shown here:the struts configuration lists the actionform beans it uses and gives the actionform classes a logical name to use within the application.1.0 vs 1.1 in str

28、uts 1.1 the actionform can also use a map (java.util.map) to store the attribute names rather than define individual properties. a new type of javabean, the dynabean, can also be used with struts 1.1 and later.you can specify the properties for a dynaactionform by using an xml element.in effect, thi

29、s does let you define actionforms in the struts configuration file.for more about actionforms, see chapter 5.custom actionsan html form uses an action parameter to tell the browser where to send the forms data. the struts framework supplies a corresponding action class to receive such data. the fram

30、ework automatically creates, populates, validates, and finally passes the appropriate actionform to the action object. the action can then get the data it needs directly from the actionform bean. heres an example:public final class logonaction extends action public actionforward perform(actionmappin

31、g mapping,actionform form,httpservletrequest request,httpservletresponse response)throws ioexception, servletexception myform myform = (myform) form;/ .return mapping.findforward(continue);an action concludes by returning an actionforward object to the controller. this allows the action to choose a

32、definition using logical names, like continue or cancel, rather than system paths.to ensure extensibility, the controller also passes the current request and response object. in practice, an action can do anything a java servlet can do.1.0 vs 1.1 in struts 1.1 a new execute method is preferred over

33、the perform method shown in our example. the perform method is deprecated but supported for backward compatibility. the execute method signature allows for better exception handling. the new exceptionhandler is covered in chapter 9.for more about action objects, see chapter 8.in addition to the acti

34、onforward, actionform, and action objects,the struts controller layer provides several other specialized components, including actionmappings and the actionservlet. struts also supports localizing your application from the controller layer.actionmappingsin a web application, every resource must be r

35、eferred to through a uniform resource identifier (uri). this includes html pages, jsp pages, and any custom actions. to give the custom actions a uri, or path, the struts framework provides an actionmapping object. like the actionforwards and actionforms, the mappings are usually defined in the xml

36、configuration file:this also allows the same action object to be used by different mappings. for example, one mapping may require validation; another may not.for more about actionmappings, see chapter 7.actionservletthe struts actionservlet works quietly behind the scenes, binding the other componen

37、ts together. although it can be subclassed, most struts 1.0 developers treat the actionservlet as a blackbox: they configure it and leave it alone. for more about configuring struts, see chapter 4.in struts 1.1, the actionservlet is easier to extend. chapter 9 covers the new extension points and con

38、figuration options for the struts 1.1 actionservlet.localizationweb applications also interact with users through prompts and messages. the struts components have localization features built in so that applications can be written for an international audience. we refer to the localization features t

39、hroughout the book. a general overview is provided in chapter developing a web application with strutsto build a web application with struts, developers will define the hyperlinks they need as actionforwards, the html forms they need as actionforms, and whatever custom server-side actions t

40、hey need as action classes.developers who need to access ejbs or jdbc databases can do so by way of the action object. this way, the presentation page does not need to interact with themodel layer.the struts action object will collect whatever data a view may need and then forward it to the presenta

41、tion page. struts provides a jsp tag library for use with jsp pages that simplifies writing html forms and accessing other data that an action may forward. other presentation devices, such as velocity templates, can also access the struts framework to create dynamic web pages. this process is shown

42、in figure 2.3.for more about using various data systems with struts, see chapter 14. see chapters 10 and 11 to learn more about creating presentation pages with struts.before moving deeper into the struts architecture, lets take a look at the issues faced by a web application framework that the arch

43、itecture must address.2.3 why we need frameworksin chapter 1, we introduced application frameworks and briefly discussed why frameworks are important. but to really understand a solution, you need to appreciate the problem. developing for the web, while rewarding, brings its own set of challenges. l

44、ets take a quick look at what makes web development so challenging.2.3.1 the weba never-ending klugeweb developers are hampered by a double web whammy. first, we are expected to use web browsers for clients. second, we must use the web protocol to communicate.web browsers communicate via hypertext t

45、ransmission protocol (http) and display pages created with hypertext markup language (html). a web browser sends out the http request and renders the html it receives in response. this is an excellent platform for serving prewritten pages that rarely change. but most of us are writing dynamic applic

46、ations with pages that are customized for each user. while there are some handy “hooks” for dynamic features, web applications go against the http/html grain.as shown in table 2.1, restrictions imposed by the web protocol and the web clients predetermine how web applications can be written. table 2.

47、1 difficulties web applications face and web application frameworks must addressrestrictions imposed byresult in these difficultiesthe protocolby default, http will accept a connection from any client on the network.changing this behavior varies from server to server.primarily, http transfers data u

48、sing simple text fields. transferring binary data requires use of a complicated extension to the protocol.http is sessionless and requires extra effort to track people using the application.http is trusting and expects that clients will provide accurate information.the clientsbrowsers are separate a

49、pplications outside the applications direct control.all browsers are not equal and support different subsets of the official standards.input from a browser may be incorrect or incomplete. input may even be hostile and contrived to harm the application.the standard web formatting language, html, cann

50、ot construct many of the interface elements found in desktop environments.creating html controls with default data is an exercise left to the pplication.sadly, the situation is not going to change any time soon. web developers must see these shortcomings as challenges to overcome. since there are so

51、 many obstacles to writing robust web applications, using a framework is vital, lest your application become an endless series of workarounds and kluges.the challenges we face when developing web applications are great. but so are the rewards. the duo of the http protocol and the html client makes w

52、eb applications accessible to people the world over. no other platform has ever been able to make that claim.2.3.2 the servlet solutionas mentioned in chapter 1, the java servlet platform sun, jst acts like a base framework to provide java web applications with a number of important capabilities. th

53、e servlet class provides a base interface for handling http requests and the ensuing response. it builds on http to provide a “session” context to help track users in the application. it provides other contexts to help applications pass data to the browsers or to other servlets in the application. j

54、ava web applications also have uniform access to basic security features that would otherwise be managed differently by different http servers.to put this all together, the servlet specification describes a container to manage the servlets. the container may also provide other services, such as a ha

55、ndler for jsps. a servlet container can include its own web server or simply act as an adjunct to an existing web server.for database access, java applications have another common framework at their disposal: jdbc. developers can write to a standard sql interface while an adapter takes care of the h

56、oary details. this makes it easier to change database vendors without rewriting the source code.for high-performance applications that access database systems on remote servers, web developers can use the enterprise javabean platform. most java application frameworks, including struts, can be used w

57、ith ejbs when they are needed. overall, this makes web applications based on java servlets very portable and relatively easy to write and maintain. servlets and jsps have made a real difference in the way we write applications. java web application frameworks like struts build on the servlet platform and try to provide developers with a seamless, kluge-free environment.2.3.3 servlet frameworksmost, if not all, java web frameworks use the sun servlet platform as a

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論