I found this in an existing Tiles configuration. Tiles is being used with SpringMVC. Can someone explain what this does?
Basically it intercepts requests for all views of the form page.*
and displays a static jsp page. What I can't figure out is how? What does {1}
do? Does it just replace the content represented by *
?
If I want to display a jsp called about.jsp
what view should the controller request? page.about.jsp
or page.about
?
Also, what is layout.page.{1}
pointing to? I can't find a layout
folder under my jsp folder.
<!-- Static pages -->
<definition name="page.*" extends="layout.main">
<put-attribute name="titleKey" value="title.{1}"/>
<put-attribute name="body" value="layout.page.{1}"/>
</definition>
The Layout definition is as follows:
<definition name="layout.main" template="/WEB-INF/templates/mainLayout.jsp"
preparer="com.company.modules.web.tiles.ABTestViewPreparer">
<put-attribute name="titleKey" value="Company Archetypical Webapp"/>
<put-attribute name="backToResults" value="" />
<put-attribute name="metaDesc" value="meta.description"/>
<put-attribute name="metaKeywords" value="meta.keywords"/>
开发者_开发知识库 <put-attribute name="header" value="/WEB-INF/templates/header.jsp"/>
<put-attribute name="searchBar" value="/WEB-INF/templates/blank.jsp"/>
<put-attribute name="nav" value="/WEB-INF/templates/blank.jsp"/>
<put-attribute name="ads" value="/WEB-INF/templates/blank.jsp"/>
<put-attribute name="body" value="/WEB-INF/templates/blank.jsp" />
<put-attribute name="footer" value="/WEB-INF/templates/footer.jsp"/>
</definition>
Any help is appreciated, I'm trying to figure it out from the Tiles documentation but it's just not clear whats going on and I don't want to hack away unless I know what I'm doing since I may not be able to revert to the original code.
{1}
gets replaced by the wildcard value
for example
page.FOO
, {1}
gets replaced with FOO
So if an action sent a user to page.FOO
titleKey
would resolve to whatever title.FOO
is in the properties file.
精彩评论