How to integrate Spring 4 with Apache Tiles 3?

Andoy Abarquez picture Andoy Abarquez · Aug 12, 2014 · Viewed 10.9k times · Source

I am using Spring framework version 4 and I get confused which folder to put the XML files, specially the tile definitions and where to find the resolver bean.

Answer

MGB picture MGB · Oct 21, 2014

The tile definition xml is specified when you define the TilesConfigurer bean. If you are using Java-based configuration this would look like:

@Bean
public TilesConfigurer tilesConfigurer(){
    TilesConfigurer tilesConfigurer = new TilesConfigurer();
    tilesConfigurer.setDefinitions(new String[] {"/WEB-INF/**/tiles.xml"});
    tilesConfigurer.setCheckRefresh(true);
    return tilesConfigurer;
}

If you are using xml-based configuration this would look like:

<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
    <property name="definitions">
        <list>
            <value>/WEB-INF/views/**/tiles.xml</value>
        </list>
    </property>
</bean>

When you specify /WEB-INF/views/**/tiles.xml, you are telling the TilesConfigurer to look for all tiles definitions recursively under the /Web-INF/views directory.