【正文】
Sun 正在盡力將新的變化反映到 JSP/servlet 體系結(jié)構(gòu)中,正如他們對(duì) Java 語言和 API 所作的更改一樣。我用 Netscape iPla 安裝這個(gè)庫時(shí)遇到一大堆問題,按理說它是第一種符合 J2EE 的應(yīng)用程序服務(wù)器。但是, ASP 開發(fā)人員會(huì)瘋狂地使用 ASP 腳本。在過去的 6 個(gè)月中,我目睹 Struts 庫從 90K 增大到 270K 以上。 ? 管理問題空間 分治是解決問題并使問題可管理的極好方法。 ActionMappings ActionMappings 是 ActionMapping 對(duì)象的一個(gè)集合。 ActionError 是 Struts 保持錯(cuò)誤列表的方式。因此, Struts 提供了它能夠理解的一個(gè)業(yè)務(wù)接口,即 Action 。 注:擴(kuò)展 Action 類時(shí)請(qǐng)注意簡(jiǎn)潔。 ? 可將多個(gè)請(qǐng)求映射到 UserActionForm 。例如, Struts 框架將從請(qǐng)求流中提取 fname ,并調(diào)用 () 。 可以通過擴(kuò)展 ActionServlet 來添加 Command 功能。 ActionServlet (Command) 創(chuàng)建并使用 Action 、 ActionForm 和 ActionForward 。 ActionForm) 之間的關(guān)系的 UML 圖 ActionServlet 類 您還記得函數(shù)映射的日子嗎?在那時(shí), 您會(huì)將某些輸入事件映射到一個(gè)函數(shù)指針上。 ActionForm bean 在會(huì)話級(jí)或請(qǐng)求級(jí)表示模 型的狀態(tài),而不是在持久級(jí)。 Web 容器將用一個(gè) HTTP 響 應(yīng)作出響應(yīng)。 ? 網(wǎng)頁設(shè)計(jì)人員不能直接參與網(wǎng)頁開發(fā)。 MVC Model 2 Web 向軟件開發(fā)人員提出了一些特有的挑戰(zhàn),最明顯的就是客戶機(jī)和服務(wù)器的無狀態(tài)連接。它對(duì)視圖或控制器一無所知。 Struts 是一種 MVC 實(shí)現(xiàn),它將 Servlet 和 JSP 標(biāo)記(屬于 J2EE 規(guī)范)用作實(shí)現(xiàn)的一部分。 簡(jiǎn)介 小學(xué)生也可以在因特網(wǎng)上發(fā)布 HTML 網(wǎng)頁。 外 文 翻 譯 學(xué) 院: 信息科學(xué)與工程學(xué)院 專 業(yè): 計(jì)算機(jī)科學(xué)與技術(shù) 學(xué)生姓名: 宋清云 學(xué)生班級(jí): 計(jì)算機(jī) 0801 班 學(xué)生學(xué)號(hào): 080405017 指導(dǎo)教師: 崔文成 指導(dǎo)教師評(píng)語 指導(dǎo)教師簽名: 年 月 日 Struts—— an opensource MVC implementation This article introduces Struts, a ModelViewController 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. Introduction Kids in grade school put HTML pages on the Inter. 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 patibility, 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 largescale Web application, you understand the term change. ModelViewController (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 and JSP 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. ModelViewController (MVC) JSP tags solved only part of our problem. We still have issues with validation, flow control, and updating the state of the application. This is where MVC es 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 application39。但是,小學(xué)生的網(wǎng)頁和專業(yè)開發(fā)的網(wǎng)站有質(zhì)的區(qū)別。盡管您可能永遠(yuǎn)不會(huì)用 Struts 實(shí)現(xiàn)一個(gè)系統(tǒng),但了解一下 Struts 或許使您能將其中的一些思想用于您以后的 Servlet 的 JSP 實(shí)現(xiàn)中。 ? View(視圖) 視圖提供模型的表示。這種無狀態(tài)行為使得模型很難將更改通知視圖 。 ? 嵌在代碼中的 HTML 很難看。 ? Controller(控制器) 控制器接收來自瀏覽器的請(qǐng)求,并決定將這個(gè)請(qǐng)求發(fā)往何處。 JSP 文件使用 JSP 標(biāo)記讀取來自 ActionForm bean 的信息。如果您對(duì)此比較熟悉,您會(huì)將配置信息放入一個(gè)文件,并在運(yùn)行時(shí)加載這個(gè)文件。如前所述, 文件配置該 Command。 ActionForm 類 ActionForm 維護(hù) Web 應(yīng)用程序的會(huì)話狀態(tài)。 ? Struts 框架在將 UserActionForm 傳遞給業(yè)務(wù)包裝 UserAction 之前將更新它的狀態(tài)。 ? UserActionForm 可跨多頁進(jìn)行映射,以執(zhí)行諸如向?qū)е惖牟僮鳌? Action 類應(yīng)該控制應(yīng)用程序的流程,而不應(yīng)該控制應(yīng)用程序的邏輯。通過擴(kuò)展 Action ,我們使得我們的業(yè)務(wù)接口與 Struts 業(yè)務(wù)接口保持兼容。 圖 4. Command (ActionServlet) 與 Model (Action) 之間的關(guān)系的 UML 圖 ActionMapping 類 輸入事件通常是在 HTTP 請(qǐng)求表單中發(fā)生的, servlet 容器將 HTTP 請(qǐng)求轉(zhuǎn)換為 HttpServletRequest 。 Struts 的優(yōu)點(diǎn) ? JSP 標(biāo)記機(jī)制的使用 標(biāo)記特性從 JSP 文件獲得可重用代碼和抽象 Java 代碼。當(dāng)然,這是一把雙刃劍。由于 Struts 中的變化,我不得不數(shù)次修改我的示例,但我不保證我的示例能與您下載的 Struts 協(xié)同工作。我會(huì)聽到這樣的話, “ 既 然我可以用 VBScript 直接編寫 COM 對(duì)象,為什么還要等 COM 開發(fā)人員來創(chuàng)建它呢? ” 通過使用標(biāo)記庫, Struts 有助于限制 JSP 文件中所需的 Java 代碼的數(shù)量。我建議您在遇到問題時(shí)訪問 Struts 用戶郵件列表的歸檔資料。您可以從 Sun 的網(wǎng)站獲得新的 JSP 和 Servlet 規(guī)范的草案。在不到 5 年的時(shí)間內(nèi),我 們 已經(jīng)目睹了從 cgi/perl 到 ISAPI/NSAPI、再到使用 VB 的 ASP、一直到現(xiàn)在的 Java 和 J2EE 的變遷。僅憑這一點(diǎn)遠(yuǎn)不能解決您的全部安裝問題,除非使用 Tomcat 。在 ASP 開發(fā)中,您應(yīng)該創(chuàng)建 COM 對(duì)象,然后編寫少量的 ASP 腳本將這些 COM 對(duì)象聯(lián)系起來。為了避免使用不贊成使用的方法,您可能隔一天就需要下載最新的 Struts。 ? MVC 實(shí)現(xiàn)樣例 如果您希望創(chuàng)建您自己的 MVC 實(shí)現(xiàn),則 Struts 可增加您的見識(shí)。這樣就使 Acti