Your application needs to be configured to work with Tiles. There are various options, depending on your needs, your application type, etc.
Tiles has always been a web application package, usually used in conjunction with Struts. Tiles 2 evolved to the point of being technology-independent, but its use in a Servlet-based web application will be the most frequent use case.
To start Tiles you have three options, just choose what is the best for your needs:
<servlet> <servlet-name>tiles</servlet-name> <servlet-class>org.apache.tiles.web.startup.TilesServlet</servlet-class> <init-param> <param-name> org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG </param-name> <param-value> /WEB-INF/tiles-defs.xml,/org/apache/tiles/classpath-defs.xml </param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet>
As you can see, the init parameter org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG specifies the path of the Tiles configuration files. You can specify it also as a context parameters.
Note: The Tiles servlet is just a startup servlet and it does not serve any request. Therefore, a mapping is not needed.
<listener> <listener-class>org.apache.tiles.web.startup.TilesListener</listener-class> </listener>
You can specify the Tiles configuration files using a context parameter.
<context-param> <param-name> org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG </param-name> <param-value> /WEB-INF/tiles-defs.xml,/org/apache/tiles/classpath-defs.xml </param-value> </context-param>
<filter> <filter-name>Tiles Filter</filter-name> <filter-class>org.apache.tiles.web.startup.TilesFilter</filter-class> <init-param> <param-name> org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG </param-name> <param-value> /WEB-INF/tiles-defs.xml,/org/apache/tiles/classpath-defs.xml </param-value> </init-param> </filter> ... <filter-mapping> <filter-name>Tiles Filter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> </filter-mapping>
TBD
You can configure Tiles internal behaviour by specifying:
For the details see Tiles configuration reference.