7.1 Installing Struts The software Java Development Kit - You need Download and Install 1.2 (or after) JDK. Download address: http://java.sun.com/j2se servlet Container - The usual selection is to download Tomcat (at least version 3.1, recommended using version 3.2). Download address: http://jakarta.apache.org/tomcat Ant Build System - If you install the package through the Struts Source Code, you must download the 1.1 or later version of the Ant Build System. In your own web app, you also recommend using Ant to build your application. Download address: http://jakarta.apache.org/ant servlet API Classes - To compile Structs yourself, or the application uses Struts, you need a servlet.jar package that contains the servlet and JSP API objects. Most servlet containers (such as Tomcat) have come with this file. Otherwise, you must download: http://jakarta.apache.org/builds/jakarta-servletAPI XML Parser - Structs requires an XML processor compatible with the Java API for XML Parsing (JAXP) specification. I recommend using Xerces. Download address: http://xml.apache.org/xerces-j Xalan XSLT Processor - If you construct your Structs system via the Structs source code, you must download and install 1_2_d01 or later version of the Xalan XSLT processor (XERCES It has been self-contained in Xalan. This processor is used to convert XML-based Structs documents to HTML documents. ? 7.2 Construct Structs via the source code 1. Download the StruCTS source code release package. 2. Set an ANT_HOME environment variable to point to your Ant directory. 3. Set the java_home environment variable to point to your JDK directory. 4. Set the servletapi_home environment variable, point to your servlet API directory (if your ClassPath already contains servlet.jar, you do not need to specify the directory) 5. Unpack the StruCTS source code package. 6. Go to the structs directory, run the following command :? ./ build.sh Dist This command will create a Struts binary release package, the directory is in ../ dist / structs (relative to your compilation directory). 7.3 Installing Struts 1. Download the Struts binary release. 2. Unpack the Struts binary release. (If you construct struts through the Struts source code, the result of Build is already unconnected Struts). The unproved Struts contains the following:? Lib / struts.jar - This file contains all Java objects for Struts. You need to copy it to your web-inf / lib directory for your web application. LIB / STRUCTS.TLD - This is a "Tag Library Descriptor" file that describes the free TAG of the Struts library. Need to copy it to the web-INF directory of your web application. WebApps / Struts-Documentation.war - This is a "Web Application Archive" file that contains all Struts documents. You can install it into the servlet container that supports Servlet API 2.2 or later (recommended using Tomcat).
WebApps / Struts-Example.war - This is a web application instance that extensively demonstrates many features of Struts. You can install it into a servlet container that is compatible with servlet2.2 or later and the JSP1.1 or later version of the servlet container (recommended using Tomcat). WebAPPS / Struts-Test.war - This web application contains many TAG test web pages supported by Struts, which can be used as an example of using the Struts Tag. You can use Struts in your own application with the following steps: 1. Copy the Struts directory's lib / struts.jar to the web-inf / lib directory of the web application. 2. Copy the lib / struts * .tld of the struts directory to the web-inf directory of the web application. 3. Modify the web-inf / web.xml file for the web application directory, add an element to define the Controller Servlet, add one
Elements to establish a correspondence between the URI request to the servlet. You can refer to the web-inf / web.xml file in the Struts example to learn more about grammar requirements.
4. Modify the web-inf / web.xml file for the web application directory so that the following Tag library definitions are included:
???????
??????????
/Web-inf/struts.tld
??????????
/Web-inf/struts.tld
???????
???????
??????????
/Web-inf/struts-bean.tld
??????????
/Web-inf/struts-bean.tld
???????
???????
??????????
/Web-inf/struts-logic.tld
??????????
/Web-inf/struts-logic.tld
???????
5. Create a web-inf / action.xml file to define the Action mapping of your web app. You can refer to the Action.xml file in the Struts example to learn more about grammar requirements.
6. Add the following Tag library definition to the JSP page using the Struts Tag library:
??????? <@ Taglib URI = "/ Web-inf / struts.tld" prefix = "struts"%>
??????? <@ Taglib URI = "/ Web-inf / struts-bean.tld" prefix = "bean"%>
??????? <@ Taglib URI = "/ Web-inf / struts-logic.tld" prefix = "logic"%>
7. Finally, don't forget to include the struts.jar file in the classpath when compiling the Java programs for your web application.