版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、strutsmvc 的一種開放源碼實現(xiàn) 專業(yè)班級:網(wǎng)絡(luò)06-1班 姓名:耿豪 學(xué)號:12鄭州輕工業(yè)學(xué)院本科畢業(yè)設(shè)計(論文)英文翻譯題 目 strutsmvc 的一種開放源碼實現(xiàn) 學(xué)生姓名 耿 豪 專業(yè)班級 網(wǎng)絡(luò)工程06-1班 學(xué) 號 12 院 (系) 計算機與通信工程學(xué)院 指導(dǎo)教師(職稱) 李健勇(副教授) 完成時間 2010年6月10日 21英文原文strutsan open-source mvc implementationmalcolm davisibm system journal,2006,44(2):33-37abstractthis article introduces stru
2、ts, 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 page imple
3、mentation.1 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, browser c
4、ompatibility, 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 designe
5、r 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 servlets
6、 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.2 model-view-controller (mvc)jsp tags solved only part of our problem. we st
7、ill 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 categories: 2.1model the model contains the core of the application
8、s 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. 2.2view the view provides the presentation of the model. it is the look of the application. the view can access the model getter
9、s, 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. 2.3controller the controller reacts to the user input. it creates and sets the model. 3 mvc model 2the web brought some unique challenges to sof
10、tware 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.another notice
11、able 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. changes to la
12、yout 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. figure 4 dis
13、plays the web adaptation of mvc, also commonly known as mvc model 2 or mvc 2. struts figure 4. mvc model 23.1struts, an mvc 2 implementationstruts is a set of cooperating classes, servlets, and jsp tags that make up a reusable mvc 2 design. this definition implies that struts is a framework, rather
14、than a library, but struts also contains an extensive tag library and utility classes that work independently of the framework. figure 5 displays an overview of struts. figure 5. struts overview3.2struts overview client browser an http request from the client browser creates an event. the web contai
15、ner will respond with an http response. controller the 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 configures the controller. business
16、logic the 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. model state the model represents the state of the application. the business objects update the applicat
17、ion 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. view the view is simply a jsp file. there is no flow logic, no business logic, and no model information - just t
18、ags. tags are one of the things that make struts unique compared to other frameworks like velocity. note: think thin when extending the action class. the action class should control the flow and not the logic of the application. by placing the business logic in a separate package or ejb, we allow fl
19、exibility and reuse.another way of thinking about action class is as the adapter design pattern. the purpose of the action is to convert the interface of a class into another interface the clients expect. adapter lets classes work together that couldn_t otherwise because of incompatibility interface
20、 (from design patterns - elements of reusable oo software by gof). the client in this instance is the actionservlet that knows nothing about our specific business class interface. therefore, struts provides a business interface it does understand, action. by extending the action, we make our busines
21、s interface compatible with struts business interface. (an interesting observation is that action is a class and not an interface. action started as an interface and changed into a class over time. nothings perfect.) 3.3detailsdisplayed in figure 6 is a stripped-down uml diagram of the org.apache.st
22、ruts.action package. figure 6 shows the minimal relationships among actionservlet (controller), actionform (form state), and action (model wrapper). figure 6. uml diagram of the relationship of the command (actionservlet) to the model (action & actionform)3.3.1the actionservlet class do you remember
23、 the days of function mappings? you would map some input event to a pointer to a function. if you where slick, you would place the configuration information into a file and load the file at run time. function pointer arrays were the good old days of structured programming in c. life is better now th
24、at we have java technology, xml, j2ee, and all that. the struts controller is a servlet that maps events (an event generally being an http post) to classes. and guess what - the controller uses a configuration file so you don_t have to hard-code the values. life changes, but stays the same. actionse
25、rvlet is the command part of the mvc implementation and is the core of the framework. actionservlet (command) creates and uses action, an actionform, and actionforward. as mentioned earlier, the struts-config.xml file configures the command. during the creation of the web project, action and actionf
26、orm are extended to solve the specific problem space. the file struts-config.xml instructs actionservlet on how to use the extended classes. there are several advantages to this approach: the entire logical flow of the application is in a hierarchical text file. this makes it easier to view and unde
27、rstand, especially with large applications. the page designer does not have to wade through java code to understand the flow of the application. the java developer does not need to recompile code when making flow changes. command functionality can be added by extending actionservlet.3.3.2the actionf
28、orm class actionform maintains the session state for the web application. actionform is an abstract class that is sub-classed for each input form model. when i say input form model, i am saying actionform represents a general concept of data that is set or updated by a html form. for instance, you m
29、ay have a useractionform that is set by an html form. the struts framework will: check to see if a useractionform exists; 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 dreadful request.
30、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, struts will also
31、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
32、class. the useractionform can be maintained at a session level. notes: the struts-config.xml file controls which html form request maps to which actionform. multiple requests can be mapped useractionform. useractionform can be mapped over multiple pages for things such as wizards. 3.3.3the action cl
33、ass 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 use action, subclass and overwrite the process() method. the actionservlet (command) passes the parameterized classes to actionform using the perf
34、orm() 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 been translated out of the request stream and into an actionform class. 3.3.4the error classes the uml diagram (figure 6) also included actionerror
35、 and actionerrors. 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.figure 7. uml diagram of the relationship of the command (actionservlet) to
36、the model (action)3.3.5the 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 dispatches the request to an action class. the struts-config.xml determines what a
37、ction 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 are containers)the actionmapping contains the knowledge of how a specific
38、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.3.6actionmappings actionmappings is a collection of actionmapping objects.3.4struts pros use of jsp tag me
39、chanism the tag feature promotes reusable code and abstracts java code from the jsp file. this feature allows nice integration into jsp-based development tools that allow authoring with tags. tag library why re-invent the wheel, or a tag library? if you cannot find something you need in the library,
40、 contribute. in addition, struts provides a starting point if you are learning jsp tag technology. open source you have all the advantages of open source, such as being able to see the code and having everyone else using the library reviewing the code. many eyes make for great code review. sample mv
41、c implementation struts offers some insight if you want to create your own mvc implementation. manage the problem space divide and conquer is a nice way of solving the problem and making the problem manageable. of course, the sword cuts both ways. the problem is more complex and needs more managemen
42、t. 3.5struts cons youth struts development is still in preliminary form. they are working toward releasing a version 1.0, but as with any 1.0 version, it does not provide all the bells and whistles. change the framework is undergoing a rapid amount of change. a great deal of change has occurred betw
43、een struts 0.5 and 1.0. you may want to download the most current struts nightly distributions, to avoid deprecated methods. in the last 6 months, i have seen the struts library grow from 90k to over 270k. i had to modify my examples several times because of changes in struts, and i am not going to
44、guarantee my examples will work with the version of struts you download. correct level of abstraction does struts provide the correct level of abstraction? what is the proper level of abstraction for the page designer? that is the $64k question. should we allow a page designer access to java code in
45、 page development? some frameworks like velocity say no, and provide yet another language to learn for web development. there is some validity to limiting java code access in ui development. most importantly, give a page designer a little bit of java, and he will use a lot of java. i saw this happen
46、 all the time in microsoft asp development. in asp development, you were supposed to create com objects and then write a little asp script to glue it all together. instead, the asp developers would go crazy with asp script. i would hear why wait for a com developer to create it when i can program it
47、 directly with vbscript? struts helps limit the amount of java code required in a jsp file via tag libraries. one such library is the logic tag, which manages conditional generation of output, but this does not prevent the ui developer from going nuts with java code. whatever type of framework you d
48、ecide to use, you should understand the environment in which you are deploying and maintaining the framework. of course, this task is easier said than done. limited scope struts is a web-based mvc solution that is meant be implemented with html, jsp files, and servlets. j2ee application support stru
49、ts requires a servlet container that supports jsp 1.1 and servlet 2.2 specifications. this alone will not solve all your install issues, unless you are using tomcat 3.2. i have had a great deal of problems installing the library with netscape iplanet 6.0, which is supposedly the first j2ee-compliant
50、 application server. i recommend visiting the struts user mailing list archive (see resources) when you run into problems. complexity separating the problem into parts introduces complexity. there is no question that some education will have to go on to understand struts. with the constant changes o
51、ccurring, this can be frustrating at times. welcome to the web. where is. i could point out other issues, for instance, where are the client side validations, adaptable workflow, and dynamic strategy pattern for the controller? however, at this point, it is too easy to be a critic, and some of the i
52、ssues are insignificant, or are reasonable for a 1.0 release. the way the struts team goes at it, struts might have these features by the time you read this article, or soon after. 3.6future of strutsthings change rapidly in this new age of software development. in less than 5 years, i have seen thi
53、ngs go from cgi/perl, to isapi/nsapi, to asp with vb, and now java and j2ee. sun is working hard to adapt changes to the jsp/servlet architecture, just as they have in the past with the java language and api. you can obtain drafts of the new jsp 1.2 and servlet 2.3 specifications from the sun web si
54、te. additionally, a standard tag library for jsp files is appearing.4. conclusionstruts with tomcat, turbine, and many other apache projects, is open source software, which is one of its major advantages. enable developers to better understand its internal implementation mechanism. struts open sourc
55、e framework created to enable developers to build on java servlet and javaserver pages (jsp) technology, web applications much easier. struts framework to provide an open standard framework of a unified, through using struts as the basis, developers are able to concentrate more on the application bu
56、siness logic. struts framework itself is to use the java servlet and javaserver pages technologies of a model-view-controller (mvc) implementation. structs framework by exploring the advantages and we believe he must have universal application.英文翻譯strutsmvc 的一種開放源碼實現(xiàn)malcolm davisibm system journal,2
57、006,44(2):33-37摘要本文介紹 struts,它是使用 servlet 和 javaserver pages 技術(shù)的一種 model-view-controller 實現(xiàn)。struts 可幫助您控制 web 項目中的變化并提高專業(yè)化水平。盡管您可能永遠(yuǎn)不會用 struts 實現(xiàn)一個系統(tǒng),但您可以將其中的一些思想用于您以后的 servlet 和 jsp 網(wǎng)頁的實現(xiàn)中。1 引言小學(xué)生也可以在因特網(wǎng)上發(fā)布 html 網(wǎng)頁。但是,小學(xué)生的網(wǎng)頁和專業(yè)開發(fā)的網(wǎng)站有質(zhì)的區(qū)別。網(wǎng)頁設(shè)計人員(或者 html 開發(fā)人員)必須理解顏色、用戶、生產(chǎn)流程、網(wǎng)頁布局、瀏覽器兼容性、圖像創(chuàng)建和 javascript 等等。設(shè)計漂亮的網(wǎng)站需要做大量的工作,大多數(shù) java 開發(fā)人員更注重創(chuàng)建優(yōu)美的對象接口,而不是用戶界面。javaserver pages (jsp) 技術(shù)為網(wǎng)頁設(shè)計人員和 java 開發(fā)人員提供了一種聯(lián)系鈕帶。如果您開發(fā)過大型 web 應(yīng)用程序,您就理解 變化 這個詞的含義?!澳P?視圖-控制器”(mvc) 就是用來幫助您控制變化的一種設(shè)計模式。mvc 減弱了業(yè)務(wù)邏輯接口和數(shù)據(jù)接口之間的耦合。struts 是一種 mvc 實現(xiàn),它將 servlet 2.2 和 jsp 1.1 標(biāo)記(屬于 j2ee 規(guī)范)用作實現(xiàn)的一部分。盡管
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五版國際金融風(fēng)險管理合同范本3篇
- 二零二五版建筑工地勞務(wù)用工及社會保障服務(wù)合同范本3篇
- 二零二五年酒店客房協(xié)議價優(yōu)惠合作合同3篇
- 2024政府采購合同環(huán)境與安全監(jiān)督協(xié)議3篇
- 2025年新型城鎮(zhèn)化項目水電設(shè)施安裝施工合同3篇
- 二零二五版板房租賃與租賃期滿資產(chǎn)評估與轉(zhuǎn)讓合同3篇
- 二零二五年度出租車司機服務(wù)規(guī)范與客戶滿意度提升合同3篇
- 二零二五年透水混凝土工程驗收與評估合同2篇
- 二零二五年智能交通管理系統(tǒng)采購合同3篇
- 二零二五版房屋代理租賃資產(chǎn)評估合同3篇
- 蓋洛普Q12解讀和實施完整版
- 2023年Web前端技術(shù)試題
- GB/T 20840.8-2007互感器第8部分:電子式電流互感器
- GB/T 14864-2013實心聚乙烯絕緣柔軟射頻電纜
- 品牌策劃與推廣-項目5-品牌推廣課件
- 信息學(xué)奧賽-計算機基礎(chǔ)知識(完整版)資料
- 發(fā)煙硫酸(CAS:8014-95-7)理化性質(zhì)及危險特性表
- 數(shù)字信號處理(課件)
- 公路自然災(zāi)害防治對策課件
- 耳鳴中醫(yī)臨床路徑
- 安徽身份證號碼前6位
評論
0/150
提交評論