Using multiple Struts configuration files

Source: Internet
Author: User
Tags config

Multiple profiles (single module)

<servlet>
 <servlet-name>action</servlet-name>
 <servlet-class>
  org.apache.struts.action.ActionServlet
 </servlet-class>
 <init-param>
  <param-name>config</param-name>
  <param-value>
   /WEB-INF/struts-config.xml,
   /WEB-INF/struts-config-2.xml
  </param-value>
 </init-param>
 <load-on-startup>1</load-on-startup>
</servlet>

When Actionservlet is loaded, Struts merges multiple files into a single file in memory.

Struts 1.1 introduces support for multiple configuration files. Each configuration file must be a valid XML file and must conform to the Struts-config XML DTD. The value of the initialization parameter Config in which these files can be declared as Actionservlet in Web.xml. You can specify these files as a comma-delimited list of paths. At run time, these files are merged into one file in memory. If duplicate elements occur, such as two different form bean declarations with the same name attribute, the last read-in configuration takes precedence.

Multi-configuration file (multiple modules)

<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
Org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name> Config</param-name>
<param-value>
/web-inf/struts-default-config.xml,
/WEB-INF/struts-def Ault-config-2.xml
</param-value>
</init-param>
<init-param>
<param-name> Config/module1</param-name>
<param-value>
/web-inf/struts-module1-config.xml
</ Param-value>
</init-param>
<init-param>
<param-name>config/module2</ Param-name>
<param-value>
/web-inf/struts-module2-config.xml,
/web-inf/struts-module2-config -2.xml,
/web-inf/struts-module2-config-3.xml
</param-value>
</init-param>
<load-on- Startup>1</load-on-startup>
</servlet>

Each module is defined by its own configuration file. Each struts application implicitly has a default module. The default module has no name. Additional modules are defined by specifying a module prefix. The prefix is the value immediately following the config/in the Actionservlet initialization parameter of struts.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.