Javatpoint Logo
Javatpoint Logo

Spring MVC Tiles Example

Spring provides integration support with apache tiles framework. So we can simply manage the layout of the Spring MVC application with the help of spring tiles support.

Advantage of Tiles support in Spring MVC

Reusability: We can reuse a single component in multiple pages like header and footer components.

Centralized control: We can control the layout of the page by a single template page only.

Easy to change the layout: By the help of single template page, we can change the layout of the page anytime. So your website can easily adopt new technologies such as bootstrap, jQuery, etc.


Directory Structure

Let's see the files of spring tiles example in eclipse.

Spring MVC Tiles Example

Spring MVC Tiles Example

1. Add dependencies to pom.xml file.

pom.xml

2. Create the bean class

Contact.java

3. Create the controller class

HelloWorldController.java

ContactController.java

4. Provide the entry of controller in the web.xml file

web.xml

5. Define the bean in the xml file

spring-servlet.xml

6. Provide the tiles.xml file

tiles.xml

7. Create the requested page

index.jsp

8. Create the other view components

hello.jsp

contact.jsp

header.jsp

footer.jsp

menu.jsp

layout.jsp

Output:

Spring MVC Tiles Example
Spring MVC Tiles Example
Spring MVC Tiles Example

Download Tiles jar file

If you are not using maven, download tiles jar.






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA