【正文】
As mentioned earlier, the file configures the Command. During the creation of the Web project, Action and ActionForm are extended to solve the specific problem space. The file instructs ActionServlet on how to use the extended classes. There are several advantages to this approach: t able to have direct involvement in page development. 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. The view provides the presentation of the model. It is the look of the application. The view can access 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. The controller reacts to the user input. It creates and sets the model. 3 MVC Model 2The Web brought some unique challenges 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 requery the server to discover modification to the state of the application.Another 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: Controller The Controller receives the request from the browser, and makes the decision where to send the request. With Struts, the Controller is a mand design pattern implemented as a servlet. The file configures the Controller. The Java developer does not need to repile code when making flow changes. Command functionality can be added by extending ActionServlet. ActionForm class ActionForm maintains the session state for the Web application. ActionForm is an abstract class that is subclassed 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 may have a UserActionForm that is set by an HTML Form. The Struts framework will: Multiple requests can be mapped UserActionForm. Change The framework is undergoing a rapid amount of change. A great deal of change has occurred between Struts and . 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. 1 引言小學(xué)生也可以在因特網(wǎng)上發(fā)布 HTML 網(wǎng)頁。Struts 是一種 MVC 實現(xiàn),它將 Servlet 和 JSP 標(biāo)記(屬于 J2EE 規(guī)范)用作實現(xiàn)的一部分。有時它包含的唯一功能就是狀態(tài)。 這種方法有幾個缺點: Client browser(客戶瀏覽器) 來自客戶瀏覽器的每個 HTTP 請求創(chuàng)建一個事件。就 Struts 而言,這是通過作為實際業(yè)務(wù)邏輯“瘦”包裝的 Action 類完成的。其中沒有流程邏輯,沒有業(yè)務(wù)邏輯,也沒有模型信息 只有標(biāo)記?,F(xiàn)在好多了,我們有了 Java 技術(shù)、XML、J2EE,等等。文件 指示 ActionServlet 如何使用這些擴(kuò)展的類。 可以通過擴(kuò)展 ActionServlet 來添加 Command 功能。 Struts 將使用 HttpServletRequest 中相應(yīng)的域設(shè)置 UserActionForm 的狀態(tài)。別的網(wǎng)頁或業(yè)務(wù)可能使用 UserActionForm ,在這些地方,驗證可能有所不同。 注:擴(kuò)展 Action 類時請注意簡潔。因此,Struts 提供了它能夠理解的一個業(yè)務(wù)接口,即 Action 。 ActionError 是 Struts 保持錯誤列表的方式。 ActionMappings 是 ActionMapping 對象的一個集合。 開放源碼 您可以獲得開放源碼的全部優(yōu)點,比如可以查看代碼并讓使用庫的每個人檢查代碼。 的缺點由于 Struts 中的變化,我不得不數(shù)次修改我的示例,但我不保證我的示例能與您下載的 Struts 協(xié)同工作。但是,ASP 開發(fā)人員會瘋狂地使用 ASP 腳本。 J2EE 應(yīng)用程序支持 Struts 需要支持 JSP 和 Servlet 規(guī)范的 servlet 容器。歡迎訪問本網(wǎng)站。 Struts開放源碼框架的創(chuàng)建是為了使開發(fā)者在構(gòu)建基于Java Servlet和JavaServer Pages(JSP)技術(shù)的Web應(yīng)用時更加容易。您可以從 Sun 的網(wǎng)站獲得新的 JSP 和 Servlet 規(guī)范的草案。 當(dāng)然,這項任務(wù)真是說起來容易做起來難。在 UI 開發(fā)中限制訪問 Java 有一定的合理性。 仍在變化中 這個框架仍在快速變化。 配置信息被轉(zhuǎn)換為一組 ActionMapping ,而后者又被放入 ActionMappings 容器中。真是金無足赤。 Action 的用途是“將類的接口轉(zhuǎn)換為客戶機(jī)所需的另一個接口。要使用 Action ,請創(chuàng)建它的子類并覆蓋 process() 方法。 注: Struts 框架在將 UserActionForm 傳遞給業(yè)務(wù)包裝 UserAction 之前將更新它的狀態(tài)。例如,您可能有一個由 HTML 表單設(shè)置的 UserActionForm 。 ActionServlet 是該 MVC 實現(xiàn)的 Command 部分,它是這一框架的核心。 圖 6. Command (ActionServlet) 與 Model (Action amp。ActionForm bean 在會話級或請求級表示模型的狀態(tài),而不是在持久級。就 Struts 而言,控制器是以 servlet 實現(xiàn)的一個命令設(shè)計模式。圖 4. MVC Model 2,MVC 2 的一種實現(xiàn)Struts 是一組相互協(xié)作的類、servlet 和 JSP 標(biāo)記,它們組成一個可重用的 MVC 2 設(shè)計。 這種無狀態(tài)行為使得模型很難將更改通知視圖。它是應(yīng)用程序的 外觀。這正是 MVC 發(fā)揮作用的地方。JavaServer Pages (JSP) 技術(shù)為網(wǎng)頁設(shè)計人員和 Java 開發(fā)人員提供了一種聯(lián)系鈕帶。 Complexity Separating the problem into parts introduces plexity. 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. Wele to the Web. 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 eye