On Fri, 16 Aug 2002, Michael Delamere wrote:

> Date: Fri, 16 Aug 2002 21:38:49 +0200
> From: Michael Delamere <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: multiple sub projects
>
> Hi,
>
> I´ve just read some chapters from the oreilly struts book in order to find
> out more about creating multiple sub-projects.  Very nice book!
>
> Ok, I know how to define another struts-config xml.  But in the case of the
> order example how do I tell struts to use the struts-order-config.xml?
>
> order.do -> use struts-order-config.xml
>
> Could someone provide me with an example please or send me a link where I
> can find out more.
>

The key is in the module prefixes.

Let's say your webapp is installed under context path "/myapp" and you
have the following configuration settingss in your web.xml file:

    <servlet>
      <servlet-name>controller</servlet-name>
      <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
      ...
      <init-param>
        <param-name>config/foo</param-name>
        <param-value>/WEB-INF/struts-config-foo.xml</param-value>
      </init-param>
      <init-param>
        <param-name>config/bar</param-name>
        <param-value>/WEB-INF/struts-config-bar.xml</param-value>
      </init-param>
    </servlet>

    <servlet-mapping>
      <servlet-name>controller</servlet-name>
      <url-pattern>*.do</url-pattern>
    </servlet-mapping>

Now, a path like "/myapp/foo/order.do" will go to the "/foo" module, while
paths like "/myapp/bar/order.do" will go to the "/bar" module.  You do the
same things with your JSP pages -- put them in "/foo" and "/bar"
subdirectories under the context root.

Note that *inside* the struts-config.xml file for a module, you do not
include the module prefix in any of the paths.  In other words, in each
module you'd still have an <action path="/order" ...> element.  Struts
will tack the module prefix onto the front where necessary, just like it
adds the context path for your webapp automatically.

> Any help would be appreciated,
>
> thanks,
>
> Michael
>

Craig


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to