Application module in Struts1.1 (Application Modules)

zhaozj2021-02-12  181

Application module in Struts1.1 (Application Modules)

A new feature of Struts 1.1 is the concept of the application module. The application module allows a single Struts application into several modules, each module has its own struts profile, JSP page, Action, and more. This new feature is to solve the largest problem of large and medium-sized development teams, that is, to better support parallel development to allow multiple configuration files instead of a single profile.

In large project development with Struts, use this new feature will be a very good choice.

Below I show this feature with a very simple example.

Usually, the most common directory structure of the file is as follows: test /..../ Web-INF /............./ Classes ......... . ../ lib ........... / *. TLD ........... / struts-config.xml ........... / web. XML ........... /Validator-rules.xml ........... /VALIDATION.XML ........... ... ./js...jsp (a simple JSP page for this example) .... / *. jsp .... If we add a separate module such as: Test1, the most common directory structure of the file is as follows: TEST /.../ Test1 **** ......... / main11.jsp (a simple JSP page for this example) .. ....... / *. jsp **** .... / Web-inf /........./ Classes ........... / lib ........... / *. TLD ........... / struts-config.xml ........... / Struts-test1-config. XML ***** ........... /Web.xml ........... /VALIDATOR-Rules.xml ........... Validation.xml ........... ... / js ... / css ... / main1.jsp (a simple JSP page for this example) ... / * .jsp ..... [**** "is newly added for new files or directories] The following XML configuration files are changed: 1.Struts-config.xml in the original action-mapping Increase SwitchAction such as: .... ....

**** .... ... "**** "The ActionMapping added to the new features] 2.Struts-test1-config.xml Add input MAPPING as follows: .... ....

.... .... 3.Web.xml .... .... action Org.apache . Struts.Action.ActionServlet config /web-inf/struts-config.xml config / test1 ***** /web-inf/struts-test1-config.xml ***** debug 3 < Init-param> Detail 3 2 .... .... Side with "****" is added to the new features] You can see the following code in Struts-Test1-Config.xml: < Action path = "/ switchdo" t Ype = "org.apache.struts.Actions.switch" /> Because navigation between Struts1.1 Modules To use org.apache.Struts.Actions.switch, if you view Struts1.1 source code can be found Org.apache.struts.Actions.Switchaction requires two parameters: Prefix and Page Next: These two parameters should be "/" starting PREFIX simple bit is the name of the new module, this example is: Test1Page This example is: login3.do in the new StrutsConfig configuration file.

Note: If you want to use the call of the module, prefix = empty string

Good way to give the module conversion below

Start Tomcathttp: // localhost: 8080 / test / switchdo.do? Prefix = / test1 & page = / login3.do calls Struts-Test1-Config.xml under /login3.dohttp://localhost:8080/test/switchdo. Do? prefix = & page = / login1.do calls Struts-Config under Struts-Config.xml, then calls Struts-Config. Under XML / Login.do, in general, the transition between modules is to be used to use org.apache.struts.Actions.Switch, and it needs to pass two parameters (generally error-in) Please note)

[Note: There is already a configuration file in the formal version of Struts1.1, 2003-07-21]

This post was originally posted in the Struts area in CJW (http://www.chinajavaworld.net)

JPLATEAU 2003-05-05

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

New Post(0)