|
Note:- In the below example we are creating the admin and register module. You can download the whole source from download link. We only show the code which is written for the modules so that you can understand the exact logic to switch the modules.
(1) Web.xml file Changes
<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</param-value> </init-param> <init-param> <param-name>config/admin</param-name> <param-value>/WEB-INF/admin/struts-admin.xml</param-value> </init-param> <init-param> <param-name>config/register</param-name> <param-value>/WEB-INF/register/struts-register.xml</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet>
(2) Struts-config.xml for default Module.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd"> <struts-config> <!-- ================================================ Form Bean Definitions --> <form-beans></form-beans> <!-- ========================================= Global Exception Definitions --> |