开发者

Use properties file inside Apache Tiles 2 config file

开发者 https://www.devze.com 2023-03-29 01:38 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号