Reputation: 11952
Is it possible to use Tiles2 with Struts 1?
I've followed the instruction available at the migration guide http://tiles.apache.org/migration/index.html
But when I try to access my actions, I get this error:
org.apache.tiles.template.NoSuchAttributeException: Attribute 'body' not found.
I have in struts-config.xml:
<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"
maxFileSize="10M" tempDir="/tmp" />
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
</plug-in>
And tiles-defs.xml
<definition name="mainTemplate" template="/common/templates/mainTemplate.jsp" />
<definition name="index" extends="mainTemplate">
<put-attribute name="body" type="string" value="/views/index/index.jsp" />
</definition>
Upvotes: 5
Views: 1634
Reputation: 1057
Make the following changes in your struts-config.xml
<controller processorClass=”org.apache.struts.tiles2.TilesRequestProcessor”/>
<plug-in className=”org.apache.struts.tiles2.TilesPlugin” >
Find the sources for the Tiles2 plugin here.
Upvotes: 1
Reputation: 23352
Yes its possible to use it with struts 1. Check their site.
Put attributes in you tiles file for mainTemplate Like:
<definition name="mainTemplate" path="/common/templates/mainTemplate.jsp">
<put name="title" value="Tiles Example" />
<put name="header" value="/header.jsp" />
<put name="menu" value="/menu.jsp" />
<put name="body" value="/body.jsp" />
<put name="footer" value="/footer.jsp" />
</definition>
If this did not work then try change your struts-config.xml
like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">
<struts-config>
<action-mappings>
<action
path="/User"
type="org.apache.struts.actions.ForwardAction"
parameter="/pages/user/user-form.jsp"/>
</action-mappings>
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml"/>
</plug-in>
</struts-config>
Upvotes: -2