馬江外文翻譯Struts.doc_第1頁
馬江外文翻譯Struts.doc_第2頁
馬江外文翻譯Struts.doc_第3頁
馬江外文翻譯Struts.doc_第4頁
馬江外文翻譯Struts.doc_第5頁
已閱讀5頁,還剩2頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

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 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 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, browser 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 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 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.Struts pros Use of JSP tag mechanism 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, 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 MVC 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 management. Struts 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 between 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 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 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 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 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 decide 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 Struts 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 application server. I recommend visiting the Struts User Mailing List archive 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 occurring, 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 issues 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. Future of StrutsThings change rapidly in this new age of software development. In less than 5 years, I have seen things 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 site. Additionally, a standard tag library for JSP files is appearing.StrutsMVC 的一種開放源碼實(shí)現(xiàn)本文介紹 Struts,它是使用 servlet 和 JavaServer Pages 技術(shù)的一種 Model-View-Controller 實(shí)現(xiàn)。Struts 可幫助您控制 Web 項(xiàng)目中的變化并提高專業(yè)化水平。盡管您可能永遠(yuǎn)不會用 Struts 實(shí)現(xiàn)一個(gè)系統(tǒng),但您可以將其中的一些思想用于您以后的 servlet 和 JSP 網(wǎng)頁的實(shí)現(xiàn)中。簡介小學(xué)生也可以在因特網(wǎng)上發(fā)布 HTML 網(wǎng)頁。但是,小學(xué)生的網(wǎng)頁和專業(yè)開發(fā)的網(wǎng)站有質(zhì)的區(qū)別。網(wǎng)頁設(shè)計(jì)人員(或者 HTML 開發(fā)人員)必須理解顏色、用戶、生產(chǎn)流程、網(wǎng)頁布局、瀏覽器兼容性、圖像創(chuàng)建和 JavaScript 等等。設(shè)計(jì)漂亮的網(wǎng)站需要做大量的工作,大多數(shù) Java 開發(fā)人員更注重創(chuàng)建優(yōu)美的對象接口,而不是用戶界面。JavaServer Pages (JSP) 技術(shù)為網(wǎng)頁設(shè)計(jì)人員和 Java 開發(fā)人員提供了一種聯(lián)系鈕帶。如果您開發(fā)過大型 Web 應(yīng)用程序,您就理解 變化 這個(gè)詞的含義?!澳P?視圖-控制器”(MVC) 就是用來幫助您控制變化的一種設(shè)計(jì)模式。MVC 減弱了業(yè)務(wù)邏輯接口和數(shù)據(jù)接口之間的耦合。Struts 是一種 MVC 實(shí)現(xiàn),它將 Servlet 2.2 和 JSP 1.1 標(biāo)記(屬于 J2EE 規(guī)范)用作實(shí)現(xiàn)的一部分。盡管您可能永遠(yuǎn)不會用 Struts 實(shí)現(xiàn)一個(gè)系統(tǒng),但了解一下 Struts 或許使您能將其中的一些思想用于您以后的 Servlet 的 JSP 實(shí)現(xiàn)中。 Struts 的優(yōu)點(diǎn) JSP 標(biāo)記機(jī)制的使用 標(biāo)記特性從 JSP 文件獲得可重用代碼和抽象 Java 代碼。這個(gè)特性能很好地集成到基于 JSP 的開發(fā)工具中,這些工具允許用標(biāo)記編寫代碼。 標(biāo)記庫 為什么要另發(fā)明一種輪子,或標(biāo)記庫呢?如果您在庫中找不到您所要的標(biāo)記,那就自己定義吧。此外,如果您正在學(xué)習(xí) JSP 標(biāo)記技術(shù),則 Struts 為您提供了一個(gè)起點(diǎn)。 開放源碼 您可以獲得開放源碼的全部優(yōu)點(diǎn),比如可以查看代碼并讓使用庫的每個(gè)人檢查代碼。許多人都可以進(jìn)行很好的代碼檢查。 MVC 實(shí)現(xiàn)樣例 如果您希望創(chuàng)建您自己的 MVC 實(shí)現(xiàn),則 Struts 可增加您的見識。 管理問題空間 分治是解決問題并使問題可管理的極好方法。當(dāng)然,這是一把雙刃劍。問題越來越復(fù)雜,并且需要越來越多的管理。 Struts 的缺點(diǎn) 仍處于發(fā)展初期 Struts 開發(fā)仍處于初級階段。他們正在向著發(fā)行版本 1.0 而努力,但與任何 1.0 版本一樣,它不可能盡善盡美。 仍在變化中 這個(gè)框架仍在快速變化。Struts 1.0 與 Struts 0.5 相比變化極大。為了避免使用不贊成使用的方法,您可能隔一天就需要下載最新的 Struts。在過去的 6 個(gè)月中,我目睹 Struts 庫從 90K 增大到 270K 以上。由于 Struts 中的變化,我不得不數(shù)次修改我的示例,但我不保證我的示例能與您下載的 Struts 協(xié)同工作。 正確的抽象級別 Struts 是否提供了正確的抽象級別?對于網(wǎng)頁設(shè)計(jì)人員而言,什么是正確的抽象級別呢?這是一個(gè)用 $64K 的文字才能解釋清楚的問題。在開發(fā)網(wǎng)頁的過程中,我們是否應(yīng)該讓網(wǎng)頁設(shè)計(jì)人員訪問 Java 代碼?某些框架(如 Velocity)說不應(yīng)該,但它提供了另一種 Web 開發(fā)語言讓我們學(xué)習(xí)。在 UI 開發(fā)中限制訪問 Java 有一定的合理性。最重要的是,如果讓網(wǎng)頁設(shè)計(jì)人員使用一點(diǎn) Java,他將使用大量的 Java。在 Microsoft ASP 的開發(fā)中,我總是看到這樣的情況。在 ASP 開發(fā)中,您應(yīng)該創(chuàng)建 COM 對象,然后編寫少量的 ASP

溫馨提示

  • 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論