Use properties file inside Apache Tiles 2 config file
I'm using Spring MVC 3 + Apache Tile 2.2 and I was just wondering if I could use properties directly from tiles-def.xml file. So my tiles-def looks like:
<definition name=".mainTemplate" extends=".client1MainTemplate">
<put-attribute name="title" value="Title1" type="string" />
</definition>
and开发者_如何学Go I'd like to put the value of the Title into the messages.properties file instead of putting it here. Any way of doing it?
Cheers
I would do something like this:
<definition name="*" extends=".mainTemplate">
<put-attribute name="viewName" value="{1}"/>
<put-attribute name="body" value="/WEB-INF/views/{1}.jsp" />
</definition>
and in your template file:
<tiles:importAttribute name="viewName"/>
<title><spring:message code="${viewName}.title"/></title>
For a view name "index", this would look for "index.title" in messages.properties.
精彩评论