Friday, January 20, 2006

Struts setup more struts-config.xml files module based

When making a larger project, you can best make more than one config files to keep the project maintainable.
This can be done by splitting up the project into modules.
More struts-config files are included in the file:
WEB-INF/web.xml
   <init-param>
      <param-name>config/form</param-name>
      <param-value>/WEB-INF/form/struts-config.xml</param-value>
   </init-param>

Here you included a struts-config.xml file for a module named "form"
To start that module, used the link in a jsp page example:
menu.jsp
<html:link module="/form" action="/startform">Start module</html:link>

Please take in mind that this 'll also set the root dir in all action links to the /form directory automatically !!
So if you look in the config file:
WEB-INF/form/struts-config.xml
   <action-mappings>
      <action path="/startform" forward="/index.jsp" />

The forward /index.jsp 'll actually open the file from the root:
form/index.jsp

No comments: