As we see the Tiles docs said https://tiles.apache.org/framework/tutorial/advanced/wildcard.html We can define a wildcard to accept arbitrary name. But if the name includes "/", for example "c4/login". Tiles will throw an exception
org.apache.tiles.definition.NoSuchDefinitionException: c4/login
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:625)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
My definition is below:
<definition name="*" template="/WEB-INF/tiles/basicLayout.jsp">
<put-attribute name="header" value="/WEB-INF/tiles/header.jsp" />
<put-attribute name="content" value="/WEB-INF/pages/{1}.jsp" />
<put-attribute name="footer" value="/WEB-INF/tiles/footer.jsp" />
</definition>
If I change definition to the example below, a name with slash inside is a开发者_高级运维ccepted.
<definition name="c4/login" template="/WEB-INF/tiles/basicLayout.jsp">
<put-attribute name="header" value="/WEB-INF/tiles/header.jsp" />
<put-attribute name="content" value="/WEB-INF/pages/c4/login.jsp" />
<put-attribute name="footer" value="/WEB-INF/tiles/footer.jsp" />
</definition>
Please advise. Thanks a lot.
I think I found a more general workaround: use **
as the wildcard:
<definition name="**" template="/WEB-INF/tiles/basicLayout.jsp">
<put-attribute name="header" value="/WEB-INF/tiles/header.jsp" />
<put-attribute name="content" value="/WEB-INF/pages/{1}.jsp" />
<put-attribute name="footer" value="/WEB-INF/tiles/footer.jsp" />
</definition>
I got a workaround solution, use the revised definition below
<definition name="*/*" template="/WEB-INF/tiles/basicLayout.jsp">
<put-attribute name="header" value="/WEB-INF/tiles/header.jsp" />
<put-attribute name="content" value="/WEB-INF/pages/{1}/{2}.jsp" />
<put-attribute name="footer" value="/WEB-INF/tiles/footer.jsp" />
</definition>
Hope this is useful for you.
精彩评论