I want to know how to remove a tile from a view. My main view is as follows

The tile configuration consists of 4 parts: the header, menu, body and footer.
Now I know that if I request a new page, I can redefine the main view, for example, to replace the body, so that I have other content displayed there.
But I want to be able to if I click on the link in the menu, which will lead me to a page that has only a title and body (without a menu or footer).

Then the user will fill out a wizard in which they can go from one page to another, and then, as soon as they are completed, he will return to the main layout again.
And this is my question: how to remove the menu and footer from the view? My question stops here.
Since there is little documentation on the tiles that I could find, I thought I would include a step-by-step example for someone trying to get a working example of using Apache Tiles and Spring MVC using the Spring Tool Suite (my version is STS 3.2.0).
STEPS To create a simple website using STS
Create a new STS project
File β New β Spring Project Template β Spring MVC Project
Select the <Spring MVC Project option
Give your project a name and top-level package

This will create a project similar to below.

- Change POM to use Spring 3.2.0.RELEASE
From:
<org.springframework-version>3.1.1.RELEASE</org.springframework-version>
To:
<org.springframework-version>3.2.0.RELEASE</org.springframework-version>
- Add the following dependencies to the POM file to include Apache Tile dependencies
<dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-api</artifactId> <version>3.0.1</version> </dependency> <dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-core</artifactId> <version>3.0.1</version> </dependency> <dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-jsp</artifactId> <version>3.0.1</version> </dependency> <dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-servlet</artifactId> <version>3.0.1</version> </dependency> <dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-template</artifactId> <version>3.0.1</version> </dependency>
- Modify "servlet-context.xml" to use TilesViewResolver instead of the standard InternalViewResolver
<beans:bean class="org.springframework.web.servlet.view.tiles3.TilesViewResolver"> <beans:property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView"></beans:property> <beans:property name="order" value="0"></beans:property> </beans:bean> <beans:bean class="org.springframework.web.servlet.view.tiles3.TilesViewResolver"> <beans:property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView"></beans:property> <beans:property name="order" value="0"></beans:property> </beans:bean>
- Add a link to find out where the tiles are configured.
<beans:bean class="org.springframework.web.servlet.view.tiles3.TilesConfigurer" id="tilesConfigurer"> <beans:property name="definitions" value="/WEB-INF/spring/tiles.xml"> </beans:property> </beans:bean>
- Now specify the view β the JSP files that will be used to specify the views ... for example. header, menu, footer and body (this may be the actual content, and usually you will have more than one body depending on what the user clicked on the menu) - the layout will look like the very first picture in this message.
JSP files created in the content view folder
header.jsp
<h2>This is the header</h2>
footer.jsp
<p>This is the footer</p>
content1.jsp
<h1>This is content page 1</h1> <p>Blah blah content 1</p>
content2.jsp
<h1>This is content page 2</h1> <p>Blah blah content 2</p>
menu.jsp
<h2>Menu</h2> <a href="">Go to home page</a><br/> <a href="page1">Display page 1</a><br/> <a href="page2">Display page 2</a>
- When the project is created, it creates the default controller "HomeController.java". This is what is used to determine where to go next by clicking on the menu items. If you open the home controller and change it to the following
package com.stp.myapp; import java.util.Locale; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; @Controller public class HomeController {
@RequestMapping(value = "/", method = RequestMethod.GET) public ModelAndView home(Locale locale, Model model) { return new ModelAndView("mainPage"); } @RequestMapping(value = "/page1", method = RequestMethod.GET) public ModelAndView viewArticle(Locale locale, Model model) { return new ModelAndView("displayPageContent1"); } @RequestMapping(value = "/page2", method = RequestMethod.GET) public ModelAndView viewEmployees(Locale locale, Model model) { return new ModelAndView("displayPageContent2"); } }
- Now you can customize the tiles
Create the "tiles.xml" file with
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN" "http://tiles.apache.org/dtds/tiles-config_2_0.dtd"> <tiles-definitions> <definition name="base.definition" template="/WEB-INF/views/mainTemplate.jsp"> <put-attribute name="title" value=""></put-attribute> <put-attribute name="header" value="/WEB-INF/views/header.jsp"></put-attribute> <put-attribute name="menu" value="/WEB-INF/views/menu.jsp"></put-attribute> <put-attribute name="body" value=""></put-attribute> <put-attribute name="footer" value="/WEB-INF/views/footer.jsp"></put-attribute> </definition> <definition name="displayPageContent1" extends="base.definition"> <put-attribute name="title" value="Page context 1 displaying..."></put-attribute> <put-attribute name="body" value="/WEB-INF/views/content1.jsp"></put-attribute> </definition> <definition name="displayPageContent2" extends="base.definition"> <put-attribute name="title" value="Employees List"></put-attribute> <put-attribute name="body" value="/WEB-INF/views/content2.jsp"></put-attribute> </definition> <definition name="mainPage" extends="base.definition"> <put-attribute name="title" value="This is the home page being displayed....."></put-attribute> <put-attribute name="body" value="/WEB-INF/views/home.jsp"></put-attribute> </definition> </tiles-definitions>
The tiles.xml file has "mainTemplate.jsp", defined as the base definition. Create the file "mainTemplate.jsp", which has the main html layout. Files have "tiles: insertAttribute", which defines the parts of the base layout that can be overridden in each view.
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title> <tiles:insertAttribute name="title" ignore="true"></tiles:insertAttribute> </title> </head> <body> <table border="1" cellpadding="2" cellspacing="2" align="left"> <tr> <td colspan="2" align="center"> <tiles:insertAttribute name="header"></tiles:insertAttribute> </td> </tr> <tr> <td> <tiles:insertAttribute name="menu"></tiles:insertAttribute> </td> <td> <tiles:insertAttribute name="body"></tiles:insertAttribute> </td> </tr> <tr> <td colspan="2" align="center"> <tiles:insertAttribute name="footer"></tiles:insertAttribute> </td> </tr> </table> </body> </html>
- In the end, you should create a file structure similar to this.
