XML definition files can be loaded using wildcard, but this behaviour is not the default, due to compatibility reasons to Tiles 2.0.x.
To use wildcards in XML definition files, you need to put the following libraries in your classpath:
If you are using Maven, simply depend on spring-web package.
To be able to specify Tiles XML definition files using wildcards, there is the need to override the Tiles application context creation. For example, if you are using parameter-based initialization, provide a new value for the org.apache.tiles.context.AbstractTilesApplicationContextFactory init parameter. For example:
<init-param> <param-name>org.apache.tiles.context.AbstractTilesApplicationContextFactory</param-name> <param-value> org.apache.tiles.servlet.context.wildcard.WildcardServletTilesApplicationContextFactory </param-value> </init-param>
To load XML definition files using wilcards you can proceed, as usual, in two ways:
<init-param> <param-name>org.apache.tiles.definition.DefinitionsFactory.DEFINITIONS_CONFIG</param-name> <param-value>/WEB-INF/tiles-defs*.xml, classpath:/org/apache/**/tiles-defs.xml</param-value> </init-param>
/** {@inheritDoc} */ @Override protected List<URL> getSourceURLs(Object context, TilesApplicationContext applicationContext, TilesRequestContextFactory contextFactory) { List<URL> urls = new ArrayList<URL>(URL_COUNT); try { Set<URL> urlSet = applicationContext .getResources("/WEB-INF/tiles-defs*.xml"); for (URL url : urlSet) { String externalForm = url.toExternalForm(); if (externalForm.indexOf('_', externalForm.lastIndexOf("/")) < 0) { urls.add(url); } } urls.add(applicationContext.getResource( "classpath:/org/apache/tiles/classpath-defs.xml")); } catch (IOException e) { throw new DefinitionsFactoryException( "Cannot load definition URLs", e); } return urls; }
Wildcard support uses Spring Framework syntax for loading files. For example:
For everything else, see Spring's documentation.