سؤال

I'm starting with Spring MVC using JSP and Apache Tiles. I've learned that I can define views in a tile definition file like:

<definition name="index" extends="base.definition">
    <put-attribute name="body" value="/WEB-INF/jsp/bodies/index.jsp" />
</definition>

However going forward like this, I'll need to repeat this simple pattern for every body template, replacing the two appearances of "index". Isn't there a way to avoid this repetition?

هل كانت مفيدة؟

المحلول

Tiles supports wildcards too. From the documentation here:

http://tiles.apache.org/framework/tutorial/advanced/wildcard.html

<definition name="bank/*" template="/layout.jsp">
    <put-attribute name="body" value="/{1}.jsp"/>
</definition>

The {1} now refers to whatever the * matched in the view that was called. However, you may find it simpler to just keep the repetition.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top