Tying It All Together: The struts-config.xml FileAs mentioned before, the Struts framework enables you to break an application down into components to simplify and speed development. The job of the struts-config.xml file is to let you specify how the components go together and identify when they should be used. Listing 3.7 shows the struts-config.xml file for the HelloWorld application. Listing 3.7 The Struts Configuration File for HelloWorld! ( struts-config.xml )<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> <!-- This is the Struts configuration file for the "Hello!" sample application --> <struts-config> <!-- ======== Form Bean Definitions =================================== --> <form-beans> <form-bean name="HelloForm" type="ch03.hello.HelloForm"/> </form-beans> <!-- ========== Action Mapping Definitions ============================== --> <action-mappings> <!-- Say Hello! --> <action path = "/HelloWorld" type = "ch03.hello.HelloAction" name = "HelloForm" scope = "request" validate = "true" input = "/hello.jsp" > <forward name="SayHello" path="/hello.jsp" /> </action> </action-mappings> <!-- ========== Message Resources Definitions =========================== --> <message-resources parameter="ch03.hello.Application"/> </struts-config> This is a bare-bones configuration file with only a single <form-bean> , one <action> , and one <message-resource> entry. Other possible elements include <plug-in> , <data-source> , and <global-forwards> , among others. More detail on these elements is provided in Chapter 10, "The struts-config.xml File: Tying It All Together." For detailed information that is guaranteed to be correct for your version of Struts, refer to the Document Type Definition (DTD) file for your particular release of Struts. For Struts version 1.1, this DTD is located at http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd. In real-world language, this configuration file says:
|