Sunday, 17 March 2013

There is a dearth of tutorials which examine Spring MVC with Apache Tiles 3. Most of them allude to this one, which is insufficient. Having recently integrated Tiles 3 into my Spring MVC project, I have decided to make a short tutorial on how to get everything running.

Whatever java controller you're using, make sure that the view you're returning matches the wildcard pattern in tiles.xml e.g., "/index" will match "*/*" in tiles.xml and you can use {2} to get the "index" string and tiles will render the tiles under the tiles/index folder :

What this essentially does is use the jsp files from the common folder, so you can avoid copying and pasting the same jsp file over and over again in all your subfolders. My directory structure now looks like this :

Notice that I don't need to have the footer.jsp and meta.jsp in all the WEB-INF/tiles subfolders.