Modular development with Struts1.1

xiaoxiao2021-03-06  41

Compared to 1.0, Struts1.1 is given to team development. This is mainly reflected in it now uses multiple profiles. There are two ways to use multiple profiles:

1. Configure multiple config files in a comma partition in Web.xml. This is a simple support for multi-module development. Each developer can configure itself config file, but the problem is that there is a plurality of config files that cannot have the same name, or the definition of ActionForm. 2, configure multiple modules in web.xml, each module uses a separate config file. This is a multi-module in the true sense, even if there is the definition of the same name in each module, it is not tight. The first configuration method is very simple: in Web.xml, this definition:

Config

/Web-inf/struts-config.xml,

/Web-inf/struts-config-registration.xml

When using, this is not different from all configuration contents to a config file.

The second is this: 1. Prepare a configuration file 2 for each module, configure the web.xml file, notify the controller

Below is a typical multimode configuration file:

Config

/Web-inf/struts-config.xml

CONFIG / CUSTOMER

/Web-inf/struts-config-customer.xml

Config / ORDER

/Web-inf/struts-config-order.xml

Two application modules and one default module are configured here. If Struts-Config-Order.xml is configured as follows:

Then you can use this URL access:

Http: // localhost: 8080 / WebApp / Order / logon.do

Where webApp is a web app name, orde is a module name, Logon is an action of the module. It should be noted that after setting a module, Struts will default the directory of the module, as above, the module name is ORDER, then Struts will consider that the module is in the Order directory. That is, the directory structure of the web application is this:

Webapp | -WEB-INF | -ORDER | -CUSTOMER

If your web application directory structure is similar below:

Webapp | -WEB-INF | -JSP | -Order | -customer

So, the definition of the Action of Logon is changed:

Forward = "/../ jsp / order / logon.jsp" />

This is because the module you declare is config / order, then in Struts, you must have a Order directory with the Web-Inf directory, so you want to use "/../jsp/order "To reference your own files in the order of ORDER.

转载请注明原文地址:https://www.9cbs.com/read-54707.html

New Post(0)