Author: Holyfair CHENE-mail: plutocsj@hotmail.com
1. Introduction Struts is an open source of webservice Framework host by ASF as a part of its Jakarta project The primary architect and developer of the Struts framework is Craig R.McClanahan.He is also the primary architect of Tomcat 4. Notes:. 1 ) Struts is not only thread-safe but thread-dependent. 2) ActionForm beans minimize subclass code and shorten subclass hierarchies. 3) The Struts tag libraries provide general-purpose functionality. 4) The Struts components are reusable by the application. 5) The Struts localization strategies reduce the need for redundant JSPs. 6) Struts is designed an open architecture. 7) Struts is lightweight. 8) Struts is standards compliant with. 9) Struts is open source and well documented. 10) Struts is model neutral 2. Some Conception of Webserve 2.1 Servervet Servlet runs in the servlet container, which can be served by the servlet container dynamic loading control server. API: HTTPSERVLETREQUEST, HTTPSESSION and ServletContext provide methods of saving and reading shared data in Request, Session, and Application ranges, respectively. 2.2 JSP The JAVA program is added in traditional HTML, and the JSP tag constitutes a JSP page. The JSP container performs syntax analysis of a JSP file request and generates a Java Servlet source file, and then does not compile generation response.
2.3 Access scope and lifecycle of shared data Page -> Request -> session -> Application (scope gradually bigger, specific reference) 2.4 JavaBean meets a specific specification Java object to define some column properties and provide access And set these properties for public methods. (Specific reference: http: //java.sum.com/products/javabeans) 2.5 cookies cookies and url Rewriting Are Two Common Ways to Keep Track of Users Between Requests. Cookies Saved in Customers end. 2.6 CGI CGI uses standard operating system features, such as environment variables and standard input and output, to create a bridge, or gateway, between the web server and other applications on the host machine. The main drawback to CGI is that it must Run A New Copy Of The CGI-Aware Program for Each Request. 2.7 WEB Components Three Association * Request Forward * URL Redirection (REDIRECT) * Include 2.8 MVC (Model, View and Controller) Force Separate the application's input, processing, and output. Example: JSP (view), servlet (controller), JavaBean 3. Exploring the struts architecture As an open frame, Struts allows Technical construction outside the JSP . When considering improving the View technology in the Struts application, people first think of often use other servlet technology to replace JSP, such as XSLT or XSLT under servlet management. The figure below describes the case where JSP is applied in the Struts framework. View consists of JSP custom tag libraries and JSP pages, where the ActionForm class is a ValueObject object similar to JavaBean, with SET and GET methods for saving customers. According to the Struts's MVC concept, ActionForm is located between View and Controller's intermediate zone. Struts provides a set of complete dedicated tags to access data in Actionform from JSP.
2.1 Struts controller components [HyperLinks: ActionForward] To the application developer, a hyperlink is a path to some resource in the application in the configuration file, we can define a forward:.
// ... return mapping.findforward ("continue");}}} Action must also declare in Struts's configuration file. Such as:
3. Configuring Struts Components Struts configuration files include the following: web.xml: The web application deployment descriptor required by the Java Servlet specification The servlet / JSP container uses this file to load and configure your application build.xml..: A file used by the Jakarta Ant build tool to compile and deploy your application Using Ant is not a requirement, but it is a popular choice among Struts developers struts-config.xml:.. The framework's deployment descriptor It is used to load and. configure various components used by the Struts framework. application.properties:This file provides the message resources for your Struts application. Like the build.xml file, it is not a strict requirement but is used by most Struts applications. 3.1 web.xml example Analysis: ------------------------------------------------ ----------------------------------- Xml Version = "1.0 "Encoding =" ISO-8859-1 ">
/ init-param> Content = "0; URL = / cxdemo / login.do"> head> "/Logon.do" /> action> action-mapings> -------------------------------------------------- -------------------------------------------- Also there is a global Exception, Controller, Data-Sources, etc. Not detailed. 3.3 Build.xml is based on ANT development based on the Struts project creation. Details can be found in the ANT manual. 4.installing the struts Core Files All The stock files That you need to run Struts are provided in the Struts library distribution. These include several JARs, the tag library descriptors, DTDs, and standard XML configuration files. This set of stock files, combined with the four files you provide, create a complete core Struts . configuration Here's the checklist: Download and unzip the Struts library distribution [ASF, Struts] Copy all the * .jar files to your application's / WEB-INF / lib folder Copy all the * .tld files to your / WEB-INF.. folder. Copy all the * .xml and * .dtd files to your / WEB-INF folder. Create your deployment descriptor (see 4.2). Create your Struts configuration file (see 4.4). Create your message resources bundle (see 4.5). Create your an T Build file (see 4.6). 5. Summary About Struts There are many aspects. Such as: 1) Struts Model Component 2) Struts Extension 3) Struts Internationalization 4) Validator Verification Frame 5) Complex abnormal processing 6) STRUTS Tag Library 7) Title Frame 8) LOG 10) StrutstestCase Test 11) Design mode 12) Struts All expansions are based on space here. Specific recommendations