You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "naveenk@lynxasia.com" <na...@lynxasia.com> on 2008/01/18 09:44:37 UTC
Problem with using Muliple tiles-defs.xml and multiple struts-config.xml in a web application
Hi,
I have been
developing a web application using struts, which has number of modules in it.
Also I am using tiles in it for views. So
I am configuring different struts-config.xml for each module. And I think there
is nothing wrong with that.
And I want to use different tiles-defs for each module. There
the problem exists.
I want my pages to travel from one module to another module
using the information in two tiles-defs.xml's. And I am not able to do that....
My struts-config.xml of two modules is ok, but the problem
is with tiles-defs.xml.
It is giving the Exception like this.....
java.lang.IllegalArgumentException: Path page.master.companyMaster does not start with a
"/" character
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1062)
org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:320)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
I am pasting the required information of my files
My files were placed in the following way
Webroot
----- pages
------masters
-------CompanyMaster.jsp
-------CompanyMasterInfo.jsp
-----
WEB-INF
-------
lib
-------
struts-config.xml
-------
struts-config-masters.xml
-------
tiles-defs.xml
-------
tiles-defs-masters.xml
This is my web.xml
<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-Masters.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>config/Masters</param-name>
<param-value>/WEB-INF/struts-config-Masters.xml</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
this is my struts-config.xml
with tiles information in it , which is used for default
<struts-config>
<controller
processorClass="org.apache.struts.tiles.TilesRequestProcessor"
bufferSize="4096"
debug="0" />
<message-resources
parameter="com.lynx.struts.ApplicationResources" />
<plug-in
className="org.apache.struts.tiles.TilesPlugin">
<set-property
property="definitions-config" value="/WEB-INF/tiles-defs.xml,
/WEB-INF/tiles-defs-masters.xml" />
<set-property
property="moduleAware" value="true" />
<set-property
property="definitions-parser-validate" value="true" />
</plug-in>
</struts-config>
this is my tiles-defs.xml
used as default
<tiles-definitions>
<!-- Base Tiles Definition -->
<definition name="base.definition"
path="/pages/SiteLayout.jsp">
<put name="header"
value="/pages/header.jsp" />
<put name="masterMenu"
value="/masterMenu.do" />
<put name="masterMenuItems"
value="/masterMenuItems.do" />
<put name="footer"
value="/pages/footer.jsp" />
</definition>
.......
</tiles-definitions>
this is my struts-config-masters.xml
for masters module
<struts-config>
<action-mappings
>
<action path="/switch"
type="org.apache.struts.actions.SwitchAction" />
<action
path="/companyMaster"
scope="request"
type="com.lynx.struts.masters.action.CompanyMasterAction"
validate="false">
<forward
name="showCompanyMaster" path="page.master.companyMaster" />
</action>
</action-mappings>
<controller
processorClass="org.apache.struts.tiles.TilesRequestProcessor"
bufferSize="4096"
debug="0" />
<message-resources
parameter="com.lynx.struts.ApplicationResources" />
<plug-in
className="org.apache.struts.tiles.TilesPlugin">
<set-property
property="definitions-config"
value="/WEB-INF/tiles-defs-masters.xml" />
<set-property
property="moduleAware" value="true" />
<set-property
property="definitions-parser-validate" value="true" />
</plug-in>
</struts-config>
this is my tiles-defs-masters.xml
for masters module
<tiles-definitions>
<!-- Base Tiles Definition -->
<definition name="base.definition.masters">
<put name="header"
value="/pages/header.jsp" />
<put name="footer"
value="/pages/footer.jsp" />
</definition>
<!-- Tiles Definition of Masters page -->
<!-- Tiles Definition of Company Master page -->
<definition name="page.master.companyMaster"
extends="base.definition.masters">
<put name="title" value="Back Office Company
Master" />
<put name="masterMenuItems"
value="/pages/Masters/CompanyMasterInfo.jsp" />
<put name="body"
value="/pages/Masters/CompanyMaster.jsp" />
</definition>
</tiles-definitions>
The moment when I pass URL as
http://127.0.0.1:8080/BackOffice/companyMaster.do im getting the above exception
Why I don't know, my application is not able to use the
second tiles-defs.xml i.e tiles-defs-masters.xml.
Even I doubt in the base
<tiles-definition> information tag.
Is there any thing wrong in any of files information?
Thanks in advance for ur
reply.
Re: Problem with using Muliple tiles-defs.xml and multiple struts-config.xml in a web application
Posted by Antonio Petrelli <an...@gmail.com>.
2008/1/18, naveenk@lynxasia.com <na...@lynxasia.com>:
>
> I want my pages to travel from one module to another module
> using the information in two tiles-defs.xml's. And I am not able to do
> that....
Tiles Definitions in one module are not visible in the other module.
Antonio