Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok, so I'm not sure that this will work for for earlier versions of Tiles and Spring (currently using Spring 3.1 and Tiles 2.2.2), but here it goes anyway. </p> <p>I realized that for some reason, when you do an import using the core tag library within a tiles template, and let's say that import in turn calls a Spring MVC controller, it will cause an infinite loop. The way that I got around this was by doing the following:</p> <ul> <li><p>Add an attribute in the tiles definition of the layout that will reference a jsp containing the code to do the import. Let's say for example:</p> <p><code>&lt;definition name="cti.layouts.fooBarLayout" template="/WEB-INF/views/layouts/foo-bar-layout.jsp"&gt; &lt;put-attribute name="body" value="/WEB-INF/views/some-body.jsp"/&gt; &lt;put-attribute name="foo" value="/WEB-INF/views/my-import.jsp"/&gt; &lt;/definition&gt;</code></p></li> </ul> <p>In this example, you want to add the import code inside of my-import.jsp. You can use the core JSTL tag <code>&lt;c:import&gt;</code></p> <ul> <li><p>Inside of foo-bar-layout.jsp, add in a tiles:insertAttribute tag wherever you want this imported page to go. Reference the name of the attribute (in this case 'foo'):</p> <p><code>&lt;tiles:insertAttribute name="foo"/&gt;</code></p></li> </ul> <p>Now you can extend from this layout without worry about an infinite loop. Not sure why this is working as I don't understand what the underlying implementation is doing, but for some reason, tiles does not allow a dynamic import to be used inside of a template page.</p> <p>Hope this helped.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload