We know that in Struts 1.0, we can only specify a configuration file for the ActionServlet in Web.xml, which is certainly no problem in our online teaching example, but in the actual application development process, there may be some troublesome . Because many developers may also need to modify the configuration file, but the configuration file can only be modified by one person, so it will definitely cause a certain extent, which will inevitably affect the development efficiency and the complaints of developers. In Struts 1.1, in order to solve this problem of parallel development, two solutions are proposed:
Support for multiple profiles support multiple profiles, which means that you can specify multiple XML configuration files for ActionServlets, with a comma-separated, such as the MailReader presentation example provided by Struts, using this method.
init-param>
servlet>
This method can solve problems with conflicts, different developers can set their own action, Actionform, etc. in different configuration files (of course, not, each developer needs their own configuration file, can follow the system Function module is divided). However, there is still a potential problem, that is, there may be conflicts between different configuration files, because the few files will eventually merge together when the ActionServlet is initialized. For example, in Struts-Config.xml, a "Forward" named success is configured in Struts-Config-Registration.xml, it is also configured to conflict. In order to completely solve this conflict, the concept of module is introduced in Struts 1.1. A module is a separate subsystem that you can perform any of the required configurations, but also don't have to worry about conflicts with other profiles. Because we talked, ActionServlets were saved in different module information in different moduleconfig objects. To use the functionality of the module, you need to prepare the following: 1. Prepare a configuration file 2 for each module, configure the web.xml file, and notify the controller to decide to use multiple modules, you need to tell the controller, This needs to be configured in the web.xml file. Below is a typical multi-module configuration:
init-param>
init-param>
init-param>
To configure multiple modules, you need to increase the
...
...
ContextRelative = "true" Path = "/ moduleb / index.do" REDIRECT = "true" /> ... global-forwards> ... Struts-Config> It can be seen that only the module name needs to be added prior to the original Path property, and the ContextRelative property is set to true. In addition, you can define a similar local TYPE = "com.ncu.test.loginaction" Name = "loginform" Scope = "request" Input = "tile.userlogin" Validate = "True"> action> action-mappings> If you already in other modules, you need to turn back to the default module, which should be similar to the following, that is, the module name is empty. In addition, you can also use org.apache.struts.Actions.switch, for example: ... TYPE = "org.apache.struts.Actions.switch" /> ... action-mappings> ...