Make a clear role in the elements in Struts-Config.xml, which has a great advantage of building a web project.
8 elements , The following describes: 1. Date-sources element Date-Sources Element is used to configure the data source required for the application. The Java language provides a javax.sql.datesource interface, and all data sources must implement the interface. The following configuration:
2. Form-beans Elements This element is primarily used to configure the class verification class. It contains the following properties: 1. ClassName: Generally, specify and specify the configuration class with the Form-bean, default is org.apache.struts.config.FormBeanconfig, if customized, the FormBeanconfig class must be extended. There is no. 2. Name: The only identification of ActionForm bean. have to. 3. TYPE: The full class name of ActionForm. have to. As shown below:
3. Global-Exceptions element This element mainly configures an exception handling, its Exception child element represents a global exception configuration. Struts takes a configuration to handle exceptions. It is used to set the mapping between Java exceptions and exception handling class org.apache.struts.Action.ExceptionHandler. It has seven properties as follows: 1. ClassName: Specifies the configuration class corresponding to the Exception element, default is: org.apache.struts.config.exceptionconfig. There is no. 2. Handler: Specify an exception class, default is: org.apache.struts.Action.exceptionHandler. There may be no 3. key: Specify that the exception is described in Resource Bundle Key 4. Path: Specifies the forwarding path when an exception occurs. 5. Scope: Specify the storage range of the ActionMessages instance, optional values include: Request and session, default to request. There is no. 6. TYPE: Specifies the name of the required processing exception class, must. 7. Bundle: Spessage bundle as follows:
5. Action-mapings element describes mapping from a particular request path to the corresponding Action class. It has the following attributes: 1. Attribute: Settings and action Actionform Beans within the Request and Session range. Such as: The Form Bean is stored in the Request range, which is set to "MyBenas", and the bean can be returned to the instance of the bean in Request.GetAttribute ("MyBenas"). 2. ClassSName: The configuration element corresponding to the action element, default is: org.apache.struts.Action.ActionMapping. 3. Forward: Forwarded URL path. 4. INCLUDE: Specifies the included URL path. 5. INPUT: Enter the URL path of the form. When the table verification fails, the request will forward the request to the URL. 6. Name: Specifies the name of the Action FormBean associated with action, which must be defined in Form-bean. 7. PATH: Specifies the path to access Action, starting with "/", no extension. 8. Parameter: Specifies the configuration parameters of the ACTGION. In the Execute () method of the Action class, you can call the getParameter () method of the ActionMApping object to read the configuration parameters. 9. ROLES: Specifies the security role that allows calling this action, between multiple characters, spaced apart, when the request is processed, the RequestProcessor determines whether the user has permission to call Action. 10. Scope: Specifies the existence scope of the ActionForm Bean, optional to request and session, default to session. 11. TYPE: Specifies the full class name of the Action class. 12. Unknown: If this is true, it means that all invalid Action URLs you can send can handle the user, default is false; 13. Validate: Specifies whether you want to call an Action FormBean's Validate method, the default is TURE. Note: Forward, Include The TYPE attribute can only be selected one item. As shown below:
6. Controller element This element is used to configure an ActionServlet. It has the following properties. 1. Buffersize: Specifies the input buffer size, optional, default is 4096 2. ClassName: Specify the configuration class corresponding to the Controller element, default is org.apache.struts.config.controllerconfig 3. CONENTTYPE: Character encoding, if This setting is overwritten in the Action and JSP web pages. 4. Locale: Specifies whether to save the Locale object to the current user's session, the default value is false. 5. ProcessorClass: Specifies the full path to the Java class responsible for the request. 6. Tempdir: Specifies the temporary work directory for processing the file. If this item is not set, the servlet container is used as a temporary work directory assigned by the web application. 7. Nochache: If True: Adjubes specific header parameters in response results: Pragma, Cache-Control, and Expise, prevent the page from being saved in the client's browser, default is false as follows:
7. Message-Resources element mainly configures localized message text, which has the following properties. 1. ClassName: The configuration class corresponding to the Message-Resources element, default is org.apache.struts.config.MessageResourcesConfig. 2. Factory: Specifies the factory class of the message resource, default is: org.apache.struts.util.propertyMessageResourcesFactory class 3. Key: Specifies the property KEY used in the servletContext object stored by the resource bundle, default is the character defined by globals.Messages_Key CRRUME, only one resource bundle is allowed to use the default property. 4. NULL: Specifies how the Messagesources class handles the key of unknown messages. If true, return an empty string. If you are false, return the relevant string, default is false 5. Prameter: Specify the resource file name of Messagesources, if : ABApplicationResources, the actual file path is: Web-inf / class.properties. Such as:
Postscript, multi-module configuration, available for multiple application applications different Struts-Config.xml